/* ============================================
   DEADLINE TRACKER - STYLES
   ============================================ */

/* ---------- Reset & Base ---------- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #1a73e8;
    --primary-dark: #1557b0;
    --success: #188038;
    --success-bg: #e6f4ea;
    --warning: #b06000;
    --warning-bg: #fef7e0;
    --danger: #c5221f;
    --danger-bg: #fce8e6;
    --gray-50: #f8f9fa;
    --gray-100: #f1f3f4;
    --gray-200: #e8eaed;
    --gray-300: #dadce0;
    --gray-500: #9aa0a6;
    --gray-700: #5f6368;
    --gray-900: #202124;
    --white: #ffffff;
    --shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.08);
    --shadow-lg: 0 4px 6px rgba(0,0,0,0.1), 0 2px 4px rgba(0,0,0,0.06);
    --radius: 8px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--gray-100);
    color: var(--gray-900);
    line-height: 1.6;
}

/* ---------- Login Page ---------- */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1a73e8 0%, #0d47a1 100%);
}

.login-container {
    width: 100%;
    max-width: 400px;
    padding: 20px;
}

.login-card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 40px;
}

.login-header {
    text-align: center;
    margin-bottom: 30px;
}

.login-header .logo {
    font-size: 48px;
    display: block;
    margin-bottom: 10px;
}

.login-header h1 {
    font-size: 24px;
    font-weight: 600;
    color: var(--gray-900);
}

.login-header p {
    color: var(--gray-500);
    font-size: 14px;
}

.login-footer {
    text-align: center;
    margin-top: 20px;
    font-size: 12px;
    color: var(--gray-500);
}

/* ---------- Form Elements ---------- */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: var(--gray-700);
    margin-bottom: 6px;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: 14px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

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

.form-group small {
    display: block;
    margin-top: 4px;
    font-size: 12px;
    color: var(--gray-500);
}

.form-group.full-width {
    grid-column: 1 / -1;
}

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 500;
    border-radius: var(--radius);
    border: none;
    cursor: pointer;
    transition: all 0.2s;
}

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

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

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

.btn-success:hover {
    background: #146c2e;
}

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

.btn-danger:hover {
    background: #a31815;
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--gray-300);
    color: var(--gray-700);
}

.btn-outline:hover {
    background: var(--gray-100);
}

.btn-full {
    width: 100%;
}

.btn-small {
    padding: 6px 12px;
    font-size: 12px;
}

.btn.loading {
    position: relative;
    color: transparent !important;
    pointer-events: none;
}

.btn.loading::after {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    top: 50%;
    left: 50%;
    margin-left: -9px;
    margin-top: -9px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: btn-spinner 0.6s linear infinite;
}

.btn-outline.loading::after {
    border-color: rgba(0, 0, 0, 0.1);
    border-top-color: var(--gray-700);
}

@keyframes btn-spinner {
    to {
        transform: rotate(360deg);
    }
}

/* ---------- App Layout ---------- */
.app-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.app-header {
    background: var(--white);
    border-bottom: 1px solid var(--gray-200);
    padding: 16px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-left .logo {
    font-size: 28px;
}

.client-name {
    font-size: 18px;
    font-weight: 600;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.user-email {
    font-size: 14px;
    color: var(--gray-500);
}

/* ---------- Tabs ---------- */
.tab-nav {
    background: var(--white);
    border-bottom: 1px solid var(--gray-200);
    padding: 0 24px;
    display: flex;
    gap: 8px;
}

.tab-btn {
    padding: 16px 20px;
    font-size: 14px;
    font-weight: 500;
    color: var(--gray-700);
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    transition: all 0.2s;
}

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

.tab-btn.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    background: var(--danger);
    color: var(--white);
    font-size: 11px;
    font-weight: 600;
    border-radius: 10px;
    margin-left: 6px;
}

/* ---------- Main Content ---------- */
.main-content {
    flex: 1;
    padding: 24px;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* ---------- Sort Dropdown ---------- */
.sort-container {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
    padding: 12px 16px;
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.sort-container label {
    font-size: 14px;
    font-weight: 500;
    color: var(--gray-700);
    white-space: nowrap;
}

.sort-container select {
    padding: 8px 12px;
    border: 1px solid var(--gray-300);
    border-radius: 6px;
    font-size: 14px;
    background: var(--white);
    cursor: pointer;
    flex: 1;
    max-width: 250px;
}

.sort-container select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(26, 115, 232, 0.2);
}

/* ---------- Deadline Cards ---------- */
.deadline-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.deadline-card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
    cursor: pointer;
    transition: box-shadow 0.2s, transform 0.2s;
    border-left: 4px solid var(--gray-300);
    touch-action: manipulation;
    -webkit-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: rgba(26, 115, 232, 0.1);
}

.deadline-card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-1px);
}

.deadline-card:active {
    transform: translateY(0);
    box-shadow: var(--shadow);
    background: var(--gray-50);
}

.deadline-card.confidence-high {
    border-left-color: var(--success);
}

.deadline-card.confidence-medium {
    border-left-color: var(--warning);
}

.deadline-card.confidence-low {
    border-left-color: var(--danger);
}

.deadline-card.status-approved {
    border-left-color: var(--success);
}

.deadline-card.status-rejected {
    border-left-color: var(--gray-500);
    opacity: 0.8;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 8px;
}

.card-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--gray-900);
}

.card-badge {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    padding: 4px 8px;
    border-radius: 4px;
}

.card-badge.high {
    background: var(--success-bg);
    color: var(--success);
}

.card-badge.medium {
    background: var(--warning-bg);
    color: var(--warning);
}

.card-badge.low {
    background: var(--danger-bg);
    color: var(--danger);
}

.card-case {
    font-size: 13px;
    color: var(--gray-500);
    margin-bottom: 8px;
}

.card-deadline {
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-category {
    font-size: 13px;
    color: var(--primary);
    font-weight: 500;
}

.card-description {
    font-size: 14px;
    color: var(--gray-700);
}

.card-date {
    font-size: 14px;
    font-weight: 600;
    color: var(--gray-900);
    margin-top: 8px;
}

.card-source {
    font-size: 12px;
    color: var(--gray-500);
    margin-top: 8px;
}

.card-rejection {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--gray-200);
    font-size: 13px;
    color: var(--danger);
}

/* ---------- Modal ---------- */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 1000;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--white);
    border-radius: var(--radius);
    width: 100%;
    max-width: 700px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-small {
    max-width: 450px;
}

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

.modal-header h2 {
    font-size: 18px;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--gray-500);
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.modal-close:hover {
    color: var(--gray-900);
}

.modal-body {
    padding: 24px;
}

.modal-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 20px;
}

/* ---------- Detail Sections ---------- */
.detail-section {
    margin-bottom: 24px;
}

.detail-section:last-child {
    margin-bottom: 0;
}

.detail-section h3 {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--gray-500);
    margin-bottom: 12px;
    letter-spacing: 0.5px;
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

.detail-grid .full {
    grid-column: 1 / -1;
}

.excerpt-box {
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 16px;
    font-size: 14px;
    color: var(--gray-700);
    font-style: italic;
}

.excerpt {
    margin-top: 16px;
}

.excerpt blockquote {
    background: var(--gray-50);
    border-left: 3px solid var(--gray-300);
    padding: 12px 16px;
    margin-top: 8px;
    font-style: italic;
    color: var(--gray-700);
    border-radius: 0 var(--radius) var(--radius) 0;
}

.ai-notes {
    background: var(--warning-bg);
    border: 1px solid #f9d77e;
    border-radius: var(--radius);
    padding: 12px;
    font-size: 13px;
    color: var(--warning);
    margin-top: 16px;
}

.source-info {
    font-size: 14px;
    color: var(--gray-700);
}

.source-info p {
    margin-bottom: 8px;
}

.source-info a {
    color: var(--primary);
    text-decoration: none;
}

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

.action-buttons {
    display: flex;
    gap: 12px;
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid var(--gray-200);
}

.action-buttons .btn {
    flex: 1;
    padding: 14px;
    font-size: 15px;
}

.email-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--primary);
    text-decoration: none;
    font-size: 14px;
}

.email-link:hover {
    text-decoration: underline;
}

/* ---------- Settings ---------- */
.settings-form {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 24px;
    max-width: 500px;
}

.settings-form h2 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 24px;
}

/* ---------- Toast ---------- */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--gray-900);
    color: var(--white);
    padding: 14px 24px;
    border-radius: var(--radius);
    font-size: 14px;
    box-shadow: var(--shadow-lg);
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 2000;
}

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

.toast.success {
    background: var(--success);
}

.toast.error {
    background: var(--danger);
}

/* ---------- Empty States ---------- */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--gray-500);
}

.empty-state .icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.empty-state h3 {
    font-size: 18px;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 8px;
}

.loading {
    text-align: center;
    padding: 40px;
    color: var(--gray-500);
}

/* ---------- Responsive ---------- */
@media (max-width: 768px) {
    .app-header {
        flex-direction: column;
        gap: 12px;
        text-align: center;
    }
    
    .header-right {
        width: 100%;
        justify-content: center;
    }
    
    .tab-nav {
        overflow-x: auto;
        padding: 0 16px;
        -webkit-overflow-scrolling: touch;
    }
    
    .tab-btn {
        white-space: nowrap;
        padding: 12px 16px;
        font-size: 13px;
    }
    
    .main-content {
        padding: 16px;
    }
    
    .deadline-list {
        gap: 16px;
    }
    
    .deadline-card {
        padding: 16px;
        min-height: 44px; /* iOS minimum touch target */
    }
    
    .card-title {
        font-size: 15px;
    }
    
    .card-deadline {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }
    
    .detail-grid {
        grid-template-columns: 1fr;
    }
    
    .action-buttons {
        flex-direction: column;
    }
    
    .action-buttons .btn {
        min-height: 48px;
    }
    
    .modal {
        padding: 0;
    }
    
    .modal-content {
        max-height: 100vh;
        height: 100vh;
        border-radius: 0;
    }
    
    .modal-body {
        padding: 16px;
        padding-bottom: 100px; /* Extra space for action buttons */
    }
    
    .btn {
        min-height: 44px;
    }
    
    /* Sort dropdown responsive */
    .sort-container {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }
    
    .sort-container select {
        max-width: 100%;
    }
}
