/* Apple-Inspired Premium UI Design */
:root {
    --apple-bg: #f5f5f7;
    --apple-white: #ffffff;
    --apple-text: #1d1d1f;
    --apple-text-secondary: #86868b;
    --apple-border: #d2d2d7;
    --apple-blue: #0071e3;
    --apple-blue-hover: #0077ed;
    --apple-green: #34c759;
    --apple-red: #ff3b30;
    --apple-orange: #ff9500;
    --apple-shadow: 0 20px 40px rgba(0, 0, 0, 0.08);
    --apple-shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.04);
    --apple-shadow-lg: 0 40px 80px rgba(0, 0, 0, 0.12);
}

* {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

html, body {
    margin: 0;
    padding: 0;
}

/* ===== LOGIN PAGE ===== */
.manus-crm-login-container {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    color: var(--apple-text);
    background: linear-gradient(135deg, #f5f5f7 0%, #ffffff 50%, #f0f0f5 100%);
    min-height: 100vh;
    padding: 40px 20px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.apple-login-box {
    background: var(--apple-white);
    padding: 60px 48px;
    border-radius: 24px;
    box-shadow: var(--apple-shadow);
    width: 100%;
    max-width: 420px;
    text-align: center;
    animation: fadeIn 0.6s ease-out;
}

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

.apple-logo {
    margin-bottom: 32px;
    display: flex;
    justify-content: center;
}

.apple-logo img {
    max-width: 180px;
    height: auto;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.05));
}

.apple-login-box h2 {
    font-size: 28px;
    font-weight: 700;
    margin: 0 0 32px;
    letter-spacing: -0.02em;
    color: var(--apple-text);
}

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

.input-group input {
    width: 100%;
    padding: 14px 16px;
    border: 1.5px solid var(--apple-border);
    border-radius: 12px;
    font-size: 16px;
    outline: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-sizing: border-box;
    background: var(--apple-white);
    color: var(--apple-text);
    font-family: inherit;
}

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

.input-group input:focus {
    border-color: var(--apple-blue);
    box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.1);
}

.input-group input:disabled {
    background: #f5f5f7;
    color: var(--apple-text-secondary);
    cursor: not-allowed;
}

.apple-btn {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, var(--apple-blue) 0%, #0077ed 100%);
    color: #fff;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 24px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 12px rgba(0, 113, 227, 0.3);
    letter-spacing: -0.01em;
}

.apple-btn:hover {
    background: linear-gradient(135deg, var(--apple-blue-hover) 0%, #0083f7 100%);
    box-shadow: 0 8px 20px rgba(0, 113, 227, 0.4);
    transform: translateY(-2px);
}

.apple-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(0, 113, 227, 0.3);
}

.login-footer {
    margin-top: 24px;
}

.login-footer a {
    color: var(--apple-blue);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: color 0.2s;
}

.login-footer a:hover {
    color: var(--apple-blue-hover);
}

/* ===== DASHBOARD PAGE ===== */
.manus-crm-dashboard-container {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    color: var(--apple-text);
    background: var(--apple-bg);
    min-height: 100vh;
    padding: 40px 20px;
}

.manus-crm-dashboard-container.apple-style {
    display: block;
    width: calc(100% - 96px);
    max-width: none;
    background: var(--apple-white);
    border-radius: 24px;
    padding: 48px;
    box-shadow: var(--apple-shadow);
    margin: 0 auto;
    animation: fadeIn 0.6s ease-out;
    box-sizing: border-box;
}

/* Dashboard Header */
.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 48px;
    padding-bottom: 24px;
    border-bottom: 1px solid #f5f5f7;
}

.header-left h1 {
    font-size: 36px;
    font-weight: 700;
    margin: 0;
    letter-spacing: -0.02em;
    color: var(--apple-text);
}

.subtitle {
    color: var(--apple-text-secondary);
    font-size: 16px;
    margin-top: 6px;
    font-weight: 500;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.apple-btn-outline {
    background: var(--apple-white);
    border: 1.5px solid var(--apple-blue);
    color: var(--apple-blue);
    padding: 10px 18px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    letter-spacing: -0.01em;
}

.apple-btn-outline:hover {
    background: var(--apple-blue);
    color: #fff;
    box-shadow: 0 4px 12px rgba(0, 113, 227, 0.3);
    transform: translateY(-2px);
}

.logout-link {
    color: var(--apple-red);
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.2s;
    letter-spacing: -0.01em;
}

.logout-link:hover {
    opacity: 0.8;
}

/* Dashboard Tabs */
.dashboard-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 32px;
    border-bottom: 1px solid #f5f5f7;
    padding-bottom: 0;
}

.tab-link {
    text-decoration: none;
    color: var(--apple-text-secondary);
    padding: 12px 20px;
    border-radius: 12px 12px 0 0;
    font-weight: 600;
    font-size: 15px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    letter-spacing: -0.01em;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
}

.tab-link:hover {
    color: var(--apple-text);
    background: #f5f5f7;
}

.tab-link.active {
    background: var(--apple-blue);
    color: #fff;
    border-bottom-color: var(--apple-blue);
}

/* Search and Filters */
.dashboard-filters {
    margin-bottom: 24px;
    display: flex;
    gap: 20px;
    align-items: flex-end;
    flex-wrap: wrap;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.filter-group label {
    font-size: 13px;
    font-weight: 600;
    color: var(--apple-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.filter-group input,
.filter-group select {
    padding: 10px 14px;
    border: 1.5px solid var(--apple-border);
    border-radius: 10px;
    background: var(--apple-white);
    font-size: 14px;
    outline: none;
    font-family: inherit;
    color: var(--apple-text);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    min-width: 200px;
}

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

.filter-group input:focus,
.filter-group select:focus {
    border-color: var(--apple-blue);
    box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.1);
}

.filter-group select {
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2386868b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 18px;
    padding-right: 36px;
}

/* Bulk Actions Bar */
.bulk-actions {
    display: none;
    gap: 12px;
    align-items: center;
    background: linear-gradient(135deg, #f5f5f7 0%, #ffffff 100%);
    padding: 16px 20px;
    border-radius: 12px;
    border: 1px solid var(--apple-border);
    margin-bottom: 24px;
    animation: slideIn 0.3s ease-out;
}

.bulk-actions.show {
    display: flex;
}

.bulk-actions span {
    font-size: 14px;
    font-weight: 600;
    color: var(--apple-text);
}

.bulk-btn {
    padding: 8px 16px;
    border-radius: 10px;
    border: none;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    letter-spacing: -0.01em;
}

.bulk-delete {
    background: var(--apple-red);
    color: #fff;
    box-shadow: 0 2px 8px rgba(255, 59, 48, 0.2);
}

.bulk-delete:hover {
    background: #ff453a;
    box-shadow: 0 4px 12px rgba(255, 59, 48, 0.3);
    transform: translateY(-2px);
}

.bulk-archive {
    background: var(--apple-orange);
    color: #fff;
    box-shadow: 0 2px 8px rgba(255, 149, 0, 0.2);
}

.bulk-archive:hover {
    background: #ff9f0a;
    box-shadow: 0 4px 12px rgba(255, 149, 0, 0.3);
    transform: translateY(-2px);
}

.bulk-restore {
    background: var(--apple-green);
    color: #fff;
    box-shadow: 0 2px 8px rgba(52, 199, 89, 0.2);
}

.bulk-restore:hover {
    background: #30b050;
    box-shadow: 0 4px 12px rgba(52, 199, 89, 0.3);
    transform: translateY(-2px);
}

/* Edit Mode Toggle */
.edit-mode-toggle {
    background: var(--apple-blue);
    color: #fff;
    border: none;
    padding: 10px 18px;
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    letter-spacing: -0.01em;
    box-shadow: 0 2px 8px rgba(0, 113, 227, 0.2);
}

.edit-mode-toggle:hover {
    background: var(--apple-blue-hover);
    box-shadow: 0 4px 12px rgba(0, 113, 227, 0.3);
    transform: translateY(-2px);
}

.edit-mode-toggle.active {
    background: var(--apple-red);
    box-shadow: 0 2px 8px rgba(255, 59, 48, 0.2);
}

.edit-mode-toggle.active:hover {
    background: #ff453a;
    box-shadow: 0 4px 12px rgba(255, 59, 48, 0.3);
}

/* Table Wrapper */
.dashboard-table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 12px;
    border: 1px solid var(--apple-border);
    width: 100%;
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* Apple Table Styling */
.apple-table {
    width: 100%;
    min-width: 100%;
    border-collapse: collapse;
    text-align: left;
    table-layout: auto;
}

.apple-table thead {
    background: #f9f9fb;
}

.apple-table th {
    padding: 14px 12px;
    font-size: 12px;
    font-weight: 700;
    color: var(--apple-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    border-bottom: 1px solid var(--apple-border);
    white-space: nowrap;
    word-break: break-word;
}

.apple-table td {
    padding: 14px 12px;
    font-size: 14px;
    border-bottom: 1px solid #f5f5f7;
    white-space: normal;
    color: var(--apple-text);
    word-break: break-word;
    overflow-wrap: break-word;
}

/* Specific column widths for better distribution */
.apple-table .checkbox-cell { width: 44px; flex-shrink: 0; }
.apple-table .date-cell { min-width: 100px; }
.apple-table .name-cell { min-width: 130px; }
.apple-table .dob-cell { min-width: 100px; }
.apple-table .address-cell { min-width: 160px; }
.apple-table .email-cell { min-width: 150px; }
.apple-table .phone-cell { min-width: 120px; }
.apple-table .state-cell { min-width: 80px; }
.apple-table .ssn-cell { min-width: 90px; }
.apple-table .app-id-cell { min-width: 120px; }
.apple-table .enroll-id-cell { min-width: 120px; }
.apple-table .action-cell { min-width: 160px; }

.apple-table tr:hover {
    background: #f9f9fb;
}

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

.checkbox-cell {
    display: none;
    width: 44px;
    text-align: center;
}

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

.edit-mode-active .checkbox-cell {
    display: table-cell;
}

.edit-mode-active .apple-table td {
    padding: 10px 8px;
}

.edit-mode-active .apple-table input,
.edit-mode-active .apple-table textarea {
    width: 100%;
    padding: 8px 10px;
    border: 1.5px solid var(--apple-blue);
    border-radius: 8px;
    font-size: 13px;
    box-sizing: border-box;
    font-family: inherit;
    color: var(--apple-text);
}

.edit-mode-active .apple-table textarea {
    min-height: 70px;
    resize: vertical;
}

.edit-mode-active .apple-table input:focus,
.edit-mode-active .apple-table textarea:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.2);
}

.badge {
    background: #f5f5f7;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    color: var(--apple-text);
    display: inline-block;
}

.save-row-btn,
.cancel-row-btn {
    padding: 6px 12px;
    border-radius: 8px;
    border: none;
    font-size: 12px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
    margin-right: 6px;
    letter-spacing: -0.01em;
}

.save-row-btn {
    background: var(--apple-green);
    color: #fff;
    box-shadow: 0 2px 6px rgba(52, 199, 89, 0.2);
}

.save-row-btn:hover {
    background: #30b050;
    box-shadow: 0 4px 10px rgba(52, 199, 89, 0.3);
    transform: translateY(-1px);
}

.cancel-row-btn {
    background: var(--apple-red);
    color: #fff;
    box-shadow: 0 2px 6px rgba(255, 59, 48, 0.2);
}

.cancel-row-btn:hover {
    background: #ff453a;
    box-shadow: 0 4px 10px rgba(255, 59, 48, 0.3);
    transform: translateY(-1px);
}

.action-cell {
    display: none;
    white-space: normal;
}

.empty-msg {
    text-align: center;
    padding: 80px 20px !important;
    color: var(--apple-text-secondary);
    font-style: italic;
    font-size: 15px;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .manus-crm-dashboard-container.apple-style {
        padding: 32px;
        width: calc(100% - 64px);
    }

    .dashboard-header {
        flex-direction: column;
        gap: 20px;
    }

    .header-right {
        width: 100%;
        justify-content: flex-start;
    }

    .dashboard-filters {
        flex-direction: column;
        gap: 12px;
    }

    .filter-group input,
    .filter-group select {
        min-width: 100%;
    }
}

@media (max-width: 768px) {
    .manus-crm-dashboard-container {
        padding: 20px 12px;
    }

    .manus-crm-dashboard-container.apple-style {
        padding: 20px;
        border-radius: 20px;
        width: calc(100% - 40px);
    }

    .dashboard-header h1 {
        font-size: 28px;
    }

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

    .checkbox-cell {
        width: 36px;
    }

    .bulk-actions {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .bulk-btn {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .manus-crm-login-container {
        padding: 20px 12px;
    }

    .apple-login-box {
        padding: 40px 24px;
        border-radius: 20px;
    }

    .apple-login-box h2 {
        font-size: 24px;
    }

    .manus-crm-dashboard-container.apple-style {
        padding: 16px;
        border-radius: 16px;
        width: calc(100% - 32px);
    }

    .dashboard-header h1 {
        font-size: 24px;
    }

    .dashboard-tabs {
        gap: 4px;
    }

    .tab-link {
        padding: 10px 14px;
        font-size: 13px;
    }

    .apple-table {
        font-size: 12px;
    }

    .apple-table th,
    .apple-table td {
        padding: 8px 6px;
    }

    .header-right {
        gap: 8px;
    }

    .apple-btn-outline,
    .edit-mode-toggle {
        padding: 8px 14px;
        font-size: 12px;
    }
}
