/* IZI Expert - Client Portal */
/* Mobile-first, matches CRM design language */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
    --primary-color: #074783;
    --primary-hover: #053668;
    --primary-light: #e8f0f8;
    --primary-glow: rgba(7, 71, 131, 0.12);
    --accent-color: #F77350;
    --accent-hover: #e5623f;
    --secondary-color: #5f6368;
    --success-color: #188038;
    --warning-color: #e37400;
    --danger-color: #d93025;
    --bg-color: #f8f9fa;
    --card-bg: #ffffff;
    --text-color: #202124;
    --text-muted: #5f6368;
    --border-color: #dadce0;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 2px 6px rgba(0, 0, 0, 0.08);
    --radius: 4px;
    --radius-lg: 8px;
    --transition: 0.15s ease;
    --surface-bg: #f8f9fa;
    --hover-bg: #f1f3f4;
    --text-secondary: #9ca3af;
    --border-light: #e8eaed;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-color);
    color: var(--text-color);
    min-height: 100vh;
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
}

.hidden { display: none !important; }

/* ========== LOGIN ========== */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface-bg);
    padding: 16px;
}

.login-page::before {
    content: '';
    position: fixed;
    width: 100%;
    height: 4px;
    background: linear-gradient(90deg, var(--primary-color), var(--accent-color));
    top: 0;
    left: 0;
}

.login-container {
    background: var(--card-bg);
    padding: 36px 28px;
    border-radius: var(--radius-lg);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 0 0 1px var(--border-color);
    width: 100%;
    max-width: 380px;
    text-align: center;
    animation: loginAppear 0.4s ease;
}

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

.login-logo {
    margin-bottom: 16px;
}

.login-container h1 {
    color: var(--primary-color);
    margin-bottom: 4px;
    font-size: 1.6rem;
    font-weight: 700;
    letter-spacing: -0.3px;
}

.login-subtitle {
    color: var(--text-muted);
    margin-bottom: 28px;
    font-size: 0.9rem;
}

.error-message {
    color: var(--danger-color);
    font-size: 0.85rem;
    margin-top: 12px;
    font-weight: 500;
    min-height: 20px;
}

/* ========== FORMS ========== */
form {
    text-align: left;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 0.825rem;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--text-color);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    font-size: 14px;
    transition: all var(--transition);
    font-family: inherit;
    background: var(--card-bg);
    color: var(--text-color);
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px var(--primary-glow);
}

.form-group input::placeholder {
    color: var(--text-secondary);
}

.password-field {
    position: relative;
}

.password-field input {
    padding-right: 40px;
}

.toggle-password {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    display: flex;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 14px 20px;
    border-top: 1px solid var(--border-color);
}

/* ========== BUTTONS ========== */
.btn-primary {
    padding: 10px 18px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    font-family: inherit;
}

.btn-primary:hover {
    background: var(--primary-hover);
    box-shadow: 0 1px 3px rgba(7, 71, 131, 0.2);
}

.btn-primary:active {
    background: #042d54;
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-secondary {
    padding: 10px 18px;
    background: var(--card-bg);
    color: var(--text-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    font-size: 14px;
    cursor: pointer;
    transition: all var(--transition);
    font-family: inherit;
    font-weight: 500;
}

.btn-secondary:hover {
    background: var(--hover-bg);
}

.btn-full {
    width: 100%;
}

.btn-refresh {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 500;
    color: var(--primary-color);
    cursor: pointer;
    transition: all var(--transition);
    font-family: inherit;
    white-space: nowrap;
}

.btn-refresh:hover {
    background: var(--primary-light);
    border-color: var(--primary-color);
}

.btn-refresh:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-refresh.spinning svg {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* ========== HEADER ========== */
.header {
    background: var(--card-bg);
    padding: 0 16px;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
    min-width: 0;
}

.logo {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.logo-text {
    font-size: 1rem;
    font-weight: 700;
    color: var(--primary-color);
    letter-spacing: -0.3px;
}

.client-inn {
    font-size: 12px;
    color: var(--text-muted);
    background: var(--surface-bg);
    padding: 2px 8px;
    border-radius: var(--radius);
    font-variant-numeric: tabular-nums;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.client-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
}

.btn-logout {
    padding: 6px 12px;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    font-size: 13px;
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition);
    font-family: inherit;
    white-space: nowrap;
}

.btn-logout:hover {
    background: var(--danger-color);
    color: white;
    border-color: var(--danger-color);
}

/* ========== PERIOD BAR ========== */
.period-bar {
    background: var(--card-bg);
    padding: 10px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border-bottom: 1px solid var(--border-color);
}

.period-selectors {
    display: flex;
    gap: 8px;
}

.period-selectors select {
    padding: 7px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    font-size: 13px;
    background: var(--card-bg);
    color: var(--text-color);
    font-family: inherit;
    cursor: pointer;
}

.period-selectors select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px var(--primary-glow);
}

/* ========== CONTENT ========== */
.main-app {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.content {
    flex: 1;
    padding: 12px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* ========== SECTIONS ========== */
.section {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    margin-bottom: 12px;
    overflow: hidden;
}

.section-header {
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-color);
    background: var(--surface-bg);
}

.section-header h2 {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-color);
    letter-spacing: -0.1px;
}

.last-update {
    font-size: 11px;
    color: var(--text-muted);
}

.section-body {
    padding: 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.section-footer {
    padding: 12px 16px;
    border-top: 1px solid var(--border-color);
    background: var(--surface-bg);
}

.loading {
    padding: 24px;
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
}

/* ========== DATA TABLE ========== */
.data-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: auto;
}

.data-table th,
.data-table td {
    padding: 8px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border-light);
    font-size: 13px;
    white-space: nowrap;
}

.data-table th {
    background: var(--surface-bg);
    font-weight: 500;
    font-size: 12px;
    color: var(--text-muted);
    position: sticky;
    top: 0;
}

.data-table tbody tr:hover {
    background: var(--hover-bg);
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

.data-table .num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* ========== INFO ROWS (key-value pairs) ========== */
.info-rows {
    padding: 0;
}

.info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border-light);
}

.info-row:last-child {
    border-bottom: none;
}

.info-label {
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 500;
}

.info-value {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-color);
    text-align: right;
}

.info-value.success { color: var(--success-color); }
.info-value.danger { color: var(--danger-color); }
.info-value.warning { color: var(--warning-color); }
.info-value.accent { color: var(--accent-color); }
.info-value.primary { color: var(--primary-color); font-weight: 600; }

/* ========== STATUS BADGES ========== */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
}

.badge-success {
    background: #e6f4ea;
    color: var(--success-color);
}

.badge-danger {
    background: #fce8e6;
    color: var(--danger-color);
}

.badge-warning {
    background: #fef7e0;
    color: var(--warning-color);
}

.badge-info {
    background: var(--primary-light);
    color: var(--primary-color);
}

/* ========== PDF BUTTON (matches CRM .file-download-btn) ========== */
.file-download-btn {
    display: inline-block;
    padding: 3px 10px;
    background: var(--primary-color);
    color: white;
    border-radius: var(--radius);
    text-decoration: none;
    font-size: 12px;
    font-weight: 500;
    transition: background var(--transition);
    cursor: pointer;
}

.file-download-btn:hover {
    background: var(--primary-hover);
}

/* ========== PDF VIEWER (matches CRM) ========== */
.pdf-viewer-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.7);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pdf-viewer-container {
    width: 90vw;
    height: 90vh;
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 32px rgba(0,0,0,0.3);
}

.pdf-viewer-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 16px;
    background: #1e293b;
    color: #fff;
    font-size: 14px;
}

.pdf-viewer-toolbar a { color: #93c5fd; text-decoration: none; font-size: 13px; }
.pdf-viewer-toolbar a:hover { text-decoration: underline; }

.pdf-viewer-close {
    background: none;
    border: none;
    color: #fff;
    font-size: 22px;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
}

.pdf-viewer-close:hover { color: #f87171; }

.pdf-viewer-iframe {
    flex: 1;
    border: none;
    width: 100%;
}

/* ========== EMPTY STATE ========== */
.empty-state {
    padding: 32px 16px;
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
}

.empty-state svg {
    margin-bottom: 8px;
    opacity: 0.4;
}

/* ========== MODALS ========== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.32);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.modal.show {
    display: flex;
}

.modal-content {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 400px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    border: 1px solid var(--border-color);
    animation: modalSlideUp 0.2s ease;
}

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

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

.modal-header h2 {
    font-size: 1.05rem;
    font-weight: 700;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.4rem;
    cursor: pointer;
    color: var(--text-muted);
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius);
}

.modal-close:hover {
    background: var(--hover-bg);
    color: var(--text-color);
}

/* ========== NOTIFICATION ========== */
.notification {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--text-color);
    color: white;
    padding: 12px 24px;
    border-radius: var(--radius-lg);
    font-size: 13px;
    font-weight: 500;
    z-index: 2000;
    transition: transform 0.3s ease;
    max-width: calc(100% - 32px);
    text-align: center;
}

.notification.show {
    transform: translateX(-50%) translateY(0);
}

.notification.success { background: var(--success-color); }
.notification.error { background: var(--danger-color); }

/* ========== PROFILE CARD (top of page) ========== */
.profile-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    gap: 12px;
}

.profile-info {
    min-width: 0;
}

.profile-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.profile-meta {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}

.profile-tax {
    text-align: right;
    flex-shrink: 0;
}

.profile-tax-type {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.profile-tax-rate {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--primary-color);
}

/* ========== RESPONSIVE ========== */
@media (max-width: 480px) {
    .header {
        padding: 0 12px;
        height: 48px;
    }

    .logo-text {
        display: none;
    }

    .client-name {
        max-width: 120px;
        font-size: 12px;
    }

    .client-inn {
        font-size: 11px;
    }

    .content {
        padding: 8px;
    }

    .section {
        margin-bottom: 8px;
    }

    .section-header {
        padding: 12px;
    }

    .section-header h2 {
        font-size: 0.85rem;
    }

    .period-bar {
        padding: 8px 12px;
        flex-wrap: wrap;
    }

    .btn-refresh span {
        display: none;
    }

    .data-table th,
    .data-table td {
        padding: 6px 8px;
        font-size: 12px;
    }

    .info-row {
        padding: 8px 12px;
    }

    .info-label,
    .info-value {
        font-size: 12px;
    }

    .profile-card {
        padding: 12px;
    }

    .profile-name {
        font-size: 13px;
    }
}

@media (min-width: 768px) {
    .content {
        padding: 16px 24px;
        max-width: 800px;
        margin: 0 auto;
        width: 100%;
    }

    .section {
        margin-bottom: 16px;
    }

    .login-container {
        padding: 40px 36px;
    }
}
