/**
 * Password Manager - Estilos CSS
 * Diseño moderno y responsive
 */

/* =====================================================
   VARIABLES CSS
   ===================================================== */
:root {
    --primary-color: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #818cf8;
    --secondary-color: #64748b;
    --success-color: #10b981;
    --error-color: #ef4444;
    --warning-color: #f59e0b;
    --background-color: #f1f5f9;
    --card-background: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
    --transition: all 0.2s ease-in-out;
}

/* =====================================================
   RESET Y BASE
   ===================================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background-color: var(--background-color);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

a {
    color: var(--primary-color);
    text-decoration: none;
    transition: var(--transition);
}

a:hover {
    color: var(--primary-dark);
}

/* =====================================================
   PÁGINA DE AUTENTICACIÓN
   ===================================================== */
.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    padding: 2rem;
}

.auth-container {
    width: 100%;
    max-width: 420px;
}

.auth-card {
    background: var(--card-background);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    padding: 2.5rem;
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.auth-header {
    text-align: center;
    margin-bottom: 2rem;
}

.auth-header .logo {
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1.5rem;
    font-size: 2.5rem;
    color: white;
}

.auth-header h1 {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.auth-header p {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

/* =====================================================
   FORMULARIOS
   ===================================================== */
.auth-form {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-group label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.form-group label i {
    color: var(--primary-color);
    width: 16px;
}

.form-group input,
.form-group select,
.form-group textarea {
    padding: 0.75rem 1rem;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    transition: var(--transition);
    background-color: white;
    width: 100%;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.password-input-wrapper {
    position: relative;
}

.password-input-wrapper input {
    padding-right: 3rem;
}

.toggle-password {
    position: absolute;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.25rem;
    transition: var(--transition);
}

.toggle-password:hover {
    color: var(--primary-color);
}

.form-help {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.form-checkbox label {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    font-weight: normal;
}

.form-checkbox input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary-color);
    cursor: pointer;
}

/* Fortaleza de contraseña */
.password-strength {
    margin-top: 0.5rem;
}

.password-strength .strength-bar {
    height: 4px;
    border-radius: 2px;
    transition: var(--transition);
    margin-bottom: 0.25rem;
}

.strength-weak {
    background-color: var(--error-color);
}

.strength-medium {
    background-color: var(--warning-color);
}

.strength-strong {
    background-color: var(--success-color);
}

.password-strength span {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* =====================================================
   BOTONES
   ===================================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: white;
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary-color) 100%);
    color: white;
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background-color: var(--secondary-color);
    color: white;
}

.btn-secondary:hover {
    background-color: #475569;
    color: white;
}

.btn-danger {
    background-color: var(--error-color);
    color: white;
}

.btn-danger:hover {
    background-color: #dc2626;
    color: white;
}

.btn-block {
    width: 100%;
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

.btn-link {
    background: none;
    color: var(--primary-color);
    padding: 0.25rem 0.5rem;
}

.btn-link:hover {
    color: var(--primary-dark);
    text-decoration: underline;
}

.btn-icon {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.btn-icon:hover {
    background-color: var(--background-color);
    color: var(--primary-color);
}

.btn-logout {
    background-color: rgba(255, 255, 255, 0.1);
    color: white;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

.btn-logout:hover {
    background-color: rgba(255, 255, 255, 0.2);
    color: white;
}

/* =====================================================
   ALERTAS
   ===================================================== */
.alert {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    border-radius: var(--radius-md);
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
}

.alert-success {
    background-color: #d1fae5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}

.alert-error {
    background-color: #fee2e2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.alert i {
    font-size: 1.1rem;
}

.mt-2 {
    margin-top: 0.5rem;
}

/* =====================================================
   FOOTER DE AUTENTICACIÓN
   ===================================================== */
.auth-footer {
    text-align: center;
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.auth-footer a {
    font-weight: 500;
}

/* =====================================================
   NAVBAR
   ===================================================== */
.navbar {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: white;
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow-md);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.25rem;
    font-weight: 600;
}

.nav-brand i {
    font-size: 1.5rem;
}

.nav-user {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.user-name {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
}

.user-name i {
    font-size: 1.25rem;
}

/* =====================================================
   CONTENEDOR PRINCIPAL
   ===================================================== */
.container {
    display: flex;
    min-height: calc(100vh - 65px);
}

/* =====================================================
   SIDEBAR
   ===================================================== */
.sidebar {
    width: 280px;
    background-color: var(--card-background);
    border-right: 1px solid var(--border-color);
    padding: 1.5rem;
    overflow-y: auto;
}

.sidebar-section {
    margin-bottom: 2rem;
}

.sidebar-section h3 {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.category-list {
    list-style: none;
}

.category-list li {
    position: relative;
    margin-bottom: 0.25rem;
}

.category-list li a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 0.75rem;
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.9rem;
    transition: var(--transition);
}

.category-list li a:hover {
    background-color: var(--background-color);
}

.category-list li.active a {
    background-color: rgba(99, 102, 241, 0.1);
    color: var(--primary-color);
    font-weight: 500;
}

.category-list li.active a i {
    color: var(--primary-color);
}

.category-list li a i {
    color: var(--text-secondary);
    width: 18px;
}

.category-list .count {
    margin-left: auto;
    background-color: var(--background-color);
    color: var(--text-secondary);
    font-size: 0.75rem;
    padding: 0.125rem 0.5rem;
    border-radius: 9999px;
}

.delete-category-form {
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    opacity: 0;
    transition: var(--transition);
}

.category-list li:hover .delete-category-form {
    opacity: 1;
}

.btn-delete-category {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.25rem;
    font-size: 0.75rem;
}

.btn-delete-category:hover {
    color: var(--error-color);
}

/* Estadísticas */
.stats .stat-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.875rem;
}

.stats .stat-item:last-child {
    border-bottom: none;
}

.stats .stat-item i {
    color: var(--primary-color);
    width: 20px;
}

.stats .stat-item span {
    color: var(--text-secondary);
    flex: 1;
}

.stats .stat-item strong {
    color: var(--text-primary);
    font-size: 1.1rem;
}

/* =====================================================
   CONTENIDO PRINCIPAL
   ===================================================== */
.main-content {
    flex: 1;
    padding: 2rem;
    overflow-y: auto;
}

.content-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.content-header h2 {
    font-size: 1.5rem;
    font-weight: 600;
}

/* Barra de búsqueda */
.search-bar {
    margin-bottom: 1.5rem;
}

.search-bar form {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.search-bar input {
    flex: 1;
    max-width: 400px;
    padding: 0.625rem 1rem 0.625rem 2.5rem;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2364748b'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: 0.75rem center;
    background-size: 1.25rem;
}

.search-bar input:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* Estado vacío */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    background-color: var(--card-background);
    border-radius: var(--radius-lg);
    border: 2px dashed var(--border-color);
}

.empty-state i {
    font-size: 4rem;
    color: var(--border-color);
    margin-bottom: 1rem;
}

.empty-state h3 {
    font-size: 1.25rem;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.empty-state p {
    color: var(--text-secondary);
}

/* Grid de contraseñas */
.passwords-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 1.5rem;
}

.password-card {
    background-color: var(--card-background);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    transition: var(--transition);
    overflow: hidden;
}

.password-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.password-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.25rem;
    border-bottom: 1px solid var(--border-color);
}

.service-icon {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: white;
    flex-shrink: 0;
}

.service-info {
    flex: 1;
    min-width: 0;
}

.service-info h4 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.category-tag {
    display: inline-block;
    font-size: 0.75rem;
    color: var(--text-secondary);
    background-color: var(--background-color);
    padding: 0.125rem 0.5rem;
    border-radius: 9999px;
}

.password-actions {
    display: flex;
    gap: 0.25rem;
}

.password-body {
    padding: 1.25rem;
}

.info-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
    font-size: 0.9rem;
}

.info-row:last-child {
    margin-bottom: 0;
}

.info-row i {
    color: var(--text-secondary);
    width: 18px;
    flex-shrink: 0;
}

.info-row a {
    color: var(--primary-color);
    word-break: break-all;
}

.info-row a:hover {
    text-decoration: underline;
}

.copy-text {
    cursor: pointer;
    transition: var(--transition);
}

.copy-text:hover {
    color: var(--primary-color);
}

.password-row {
    align-items: flex-start;
}

.password-field {
    display: flex;
    gap: 0.5rem;
    flex: 1;
}

.password-field input {
    flex: 1;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    background-color: var(--background-color);
}

.btn-toggle-password,
.btn-copy {
    background: none;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 0.5rem;
    cursor: pointer;
    color: var(--text-secondary);
    transition: var(--transition);
}

.btn-toggle-password:hover,
.btn-copy:hover {
    background-color: var(--background-color);
    color: var(--primary-color);
}

.info-row.notes {
    align-items: flex-start;
}

.info-row.notes span {
    color: var(--text-secondary);
    font-size: 0.85rem;
    line-height: 1.5;
}

.password-footer {
    padding: 0.75rem 1.25rem;
    background-color: var(--background-color);
    border-top: 1px solid var(--border-color);
}

.password-footer small {
    color: var(--text-secondary);
    font-size: 0.8rem;
}

/* =====================================================
   MODALES
   ===================================================== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal-content {
    background-color: var(--card-background);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    animation: modalSlideIn 0.2s ease-out;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
    font-size: 1.125rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.modal-header h3 i {
    color: var(--primary-color);
}

.btn-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.25rem;
    line-height: 1;
    transition: var(--transition);
}

.btn-close:hover {
    color: var(--text-primary);
}

.modal form {
    padding: 1.25rem;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

/* =====================================================
   TOAST NOTIFICATION
   ===================================================== */
.toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background-color: var(--text-primary);
    color: white;
    padding: 1rem 1.5rem;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.3s ease-out;
    z-index: 1100;
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}

.toast i {
    color: var(--success-color);
}

/* =====================================================
   RESPONSIVE
   ===================================================== */
@media (max-width: 1024px) {
    .sidebar {
        width: 240px;
    }
}

@media (max-width: 768px) {
    .navbar {
        padding: 1rem;
    }
    
    .user-name span {
        display: none;
    }
    
    .container {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        padding: 1rem;
    }
    
    .sidebar-section.stats {
        display: none;
    }
    
    .category-list {
        display: flex;
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    
    .category-list li {
        margin-bottom: 0;
    }
    
    .category-list li a {
        padding: 0.5rem 0.75rem;
        white-space: nowrap;
    }
    
    .delete-category-form {
        display: none;
    }
    
    .main-content {
        padding: 1rem;
    }
    
    .content-header {
        flex-direction: column;
        gap: 1rem;
        align-items: flex-start;
    }
    
    .search-bar form {
        flex-wrap: wrap;
    }
    
    .search-bar input {
        max-width: none;
        width: 100%;
    }
    
    .passwords-grid {
        grid-template-columns: 1fr;
    }
    
    .auth-card {
        padding: 1.5rem;
    }
}

@media (max-width: 480px) {
    .auth-page {
        padding: 1rem;
    }
    
    .password-header {
        flex-wrap: wrap;
    }
    
    .password-actions {
        width: 100%;
        justify-content: flex-end;
        margin-top: 0.5rem;
    }
}

/* =====================================================
   UTILIDADES
   ===================================================== */
.hidden {
    display: none !important;
}

.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

.mb-1 {
    margin-bottom: 0.5rem;
}

.mb-2 {
    margin-bottom: 1rem;
}

.mb-3 {
    margin-bottom: 1.5rem;
}
