/* CSS Variables for Theming */
:root {
    /* Light Theme */
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --secondary-color: #64748b;
    --background-color: #f8fafc;
    --surface-color: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --success-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --transition: all 0.3s ease;
}

/* Dark Theme */
[data-theme="dark"] {
    --background-color: #0f172a;
    --surface-color: #1e293b;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --border-color: #334155;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4), 0 2px 4px -1px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5), 0 4px 6px -2px rgba(0, 0, 0, 0.4);
}

/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--background-color);
    color: var(--text-primary);
    transition: var(--transition);
    line-height: 1.6;
}

/* Utility Classes */
.hidden {
    display: none !important;
}

.active {
    display: block;
}

/* Modal Styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
}

.modal.active {
    display: flex;
}

.modal-content {
    background-color: var(--surface-color);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    width: 90%;
    max-width: 500px;
    animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* Authentication Styles */
.auth-container {
    padding: 40px 24px;
    text-align: center;
}

.auth-container h2 {
    font-size: 1.8rem;
    margin-bottom: 24px;
    color: var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

/* Dashboard Styles */
.dashboard {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header Styles */
.header {
    background-color: var(--surface-color);
    box-shadow: var(--shadow-sm);
    padding: 16px 0;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header h1 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--primary-color);
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-actions {
    display: flex;
    gap: 12px;
}

/* Main Content */
.main-content {
    flex: 1;
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px;
    width: 100%;
}

/* Button Styles */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    outline: none;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn:active {
    transform: translateY(0);
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background-color: var(--primary-hover);
}

.btn-secondary {
    background-color: var(--secondary-color);
    color: white;
}

.btn-secondary:hover {
    background-color: #475569;
}

.btn-danger {
    background-color: var(--danger-color);
    color: white;
}

.btn-danger:hover {
    background-color: #dc2626;
}

.btn-icon {
    padding: 10px;
    background-color: transparent;
    color: var(--text-secondary);
    border-radius: 6px;
}

.btn-icon:hover {
    background-color: rgba(37, 99, 235, 0.1);
    color: var(--primary-color);
}

.btn-lg {
    padding: 12px 24px;
    font-size: 1.1rem;
}

/* Form Styles */
.form-group {
    margin-bottom: 20px;
    padding: 0 24px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-primary);
    font-size: 0.95rem;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 0.95rem;
    background-color: var(--background-color);
    color: var(--text-primary);
    transition: var(--transition);
    outline: none;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
}

.form-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    padding: 20px 24px;
    border-top: 1px solid var(--border-color);
}

/* Password Input Group */
.password-input-group {
    position: relative;
    display: flex;
    align-items: center;
}

.password-input-group input {
    padding-right: 80px;
}

.password-toggle,
.password-generate {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 8px;
    border-radius: 4px;
    transition: var(--transition);
}

.password-generate {
    right: 44px;
}

.password-toggle:hover,
.password-generate:hover {
    color: var(--primary-color);
    background-color: rgba(37, 99, 235, 0.1);
    transform: translateY(-50%);
}

/* Add Credential Section */
.add-credential-section {
    margin-bottom: 24px;
    display: flex;
    justify-content: flex-end;
}

/* Search and Filter Section */
.search-filter-section {
    display: flex;
    gap: 16px;
    margin-bottom: 24px;
    align-items: center;
    flex-wrap: wrap;
}

.search-box {
    flex: 1;
    min-width: 250px;
    position: relative;
}

.search-box i {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
}

.search-box input {
    width: 100%;
    padding: 12px 16px 12px 48px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 0.95rem;
    background-color: var(--background-color);
    color: var(--text-primary);
    transition: var(--transition);
}

.search-box input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.filter-options select {
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 0.95rem;
    background-color: var(--background-color);
    color: var(--text-primary);
    min-width: 150px;
}

/* Credentials List */
.credentials-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 20px;
}

.credential-card {
    background-color: var(--surface-color);
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
    padding: 20px;
    transition: var(--transition);
    border: 1px solid var(--border-color);
}

.credential-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.credential-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 16px;
}

.credential-service {
    display: flex;
    align-items: center;
    gap: 12px;
}

.credential-service i {
    width: 40px;
    height: 40px;
    background-color: var(--primary-color);
    color: white;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

.credential-title {
    flex: 1;
}

.credential-title h3 {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.credential-title p {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.credential-actions {
    display: flex;
    gap: 8px;
}

.credential-body {
    margin-bottom: 16px;
}

.credential-field {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding: 8px 0;
}

.credential-field:last-child {
    margin-bottom: 0;
}

.credential-field label {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.credential-field-value {
    display: flex;
    align-items: center;
    gap: 8px;
}

.credential-field-value span {
    font-size: 0.95rem;
    color: var(--text-primary);
    font-weight: 500;
}

.copy-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 6px;
    border-radius: 4px;
    transition: var(--transition);
}

.copy-btn:hover {
    color: var(--primary-color);
    background-color: rgba(37, 99, 235, 0.1);
}

.credential-notes {
    background-color: rgba(37, 99, 235, 0.05);
    padding: 12px;
    border-radius: 8px;
    border-left: 3px solid var(--primary-color);
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* Responsive Design */
@media (max-width: 768px) {
    .main-content {
        padding: 16px;
    }

    .header-content {
        padding: 0 16px;
    }

    .header h1 {
        font-size: 1.3rem;
    }

    .search-filter-section {
        flex-direction: column;
        align-items: stretch;
    }

    .search-box {
        min-width: auto;
    }

    .credentials-list {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .form-actions {
        flex-direction: column;
    }

    .form-actions button {
        width: 100%;
    }

    .credential-header {
        flex-direction: column;
        gap: 12px;
    }

    .credential-actions {
        align-self: flex-end;
    }
}

@media (max-width: 480px) {
    .auth-container {
        padding: 30px 16px;
    }

    .auth-container h2 {
        font-size: 1.5rem;
    }

    .form-group {
        padding: 0 16px;
    }

    .form-actions {
        padding: 16px;
    }

    .modal-header {
        padding: 16px;
    }

    .modal-header h3 {
        font-size: 1.3rem;
    }
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.credential-card {
    animation: fadeIn 0.3s ease-out;
}

/* Toast Notification */
.toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    padding: 12px 20px;
    border-radius: 8px;
    color: white;
    font-weight: 500;
    z-index: 1000;
    animation: slideIn 0.3s ease-out;
    box-shadow: var(--shadow-lg);
}

/* Settings Modal Styles */
.settings-section {
    margin-bottom: 24px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--border-color);
}

.settings-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.settings-section h4 {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--primary-color);
}

.status-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    background-color: var(--background-color);
    padding: 16px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.status-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
}

.status-label {
    font-weight: 500;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.status-value {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.9rem;
}

.status-value.success {
    color: var(--success-color);
}

.status-value.error {
    color: var(--danger-color);
}

.status-value.warning {
    color: var(--warning-color);
}

/* Password Section Styles */
.password-section {
    background-color: var(--background-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 24px;
}

.password-section h4 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--text-primary);
}

.password-section:last-child {
    margin-bottom: 0;
}

.toast-success {
    background-color: var(--success-color);
}

.toast-error {
    background-color: var(--danger-color);
}

.toast-warning {
    background-color: var(--warning-color);
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Loading State */
.loading {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 40px;
    color: var(--text-secondary);
}

.loading::after {
    content: '';
    width: 24px;
    height: 24px;
    border: 2px solid var(--border-color);
    border-top: 2px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-left: 12px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}