/* ===== Global Styles ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #2563eb;
    --secondary-color: #7c3aed;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --info-color: #3b82f6;
    --dark-color: #1e293b;
    --light-color: #f8fafc;
    --border-color: #e2e8f0;
    --text-primary: #0f172a;
    --text-secondary: #64748b;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: var(--text-primary);
    line-height: 1.6;
}

/* ===== Login Screen ===== */
.login-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    padding: 20px;
}

.login-screen.hidden {
    display: none;
}

.login-container {
    max-width: 450px;
    width: 100%;
}

.login-logo {
    text-align: center;
    color: white;
    margin-bottom: 30px;
}

.login-logo i {
    font-size: 64px;
    margin-bottom: 15px;
}

.login-logo h1 {
    font-size: 36px;
    font-weight: 700;
    margin-bottom: 5px;
}

.login-logo p {
    font-size: 16px;
    opacity: 0.9;
}

.login-card {
    background: white;
    border-radius: 16px;
    padding: 40px;
    box-shadow: var(--shadow-xl);
    animation: slideUp 0.4s ease;
}

.login-card h2 {
    font-size: 24px;
    color: var(--text-primary);
    margin-bottom: 30px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.login-card h2 i {
    color: var(--primary-color);
}

.btn-block {
    width: 100%;
    justify-content: center;
}

.login-footer {
    text-align: center;
    margin-top: 25px;
}

.login-footer p {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 10px;
}

.btn-link {
    background: none;
    border: none;
    color: var(--primary-color);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    text-decoration: underline;
}

.btn-link:hover {
    color: #1d4ed8;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px;
}

/* ===== Header ===== */
.header {
    background: white;
    box-shadow: var(--shadow-md);
    position: sticky;
    top: 0;
    z-index: 100;
    display: none;
}

.header.active {
    display: block;
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 0;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 24px;
    color: var(--primary-color);
    font-weight: 700;
}

.logo i {
    font-size: 32px;
}

.logo h1 {
    font-size: 24px;
    font-weight: 700;
}

.nav-menu {
    display: flex;
    gap: 8px;
}

.nav-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.3s ease;
}

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

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

.nav-btn i {
    font-size: 18px;
}

/* ===== Main Content ===== */
.main-content {
    padding: 30px 0;
    display: none;
}

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

.section {
    display: none;
    background: white;
    border-radius: 16px;
    padding: 30px;
    box-shadow: var(--shadow-xl);
    animation: fadeIn 0.3s ease;
}

.section.active {
    display: block;
}

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

.section-header {
    margin-bottom: 30px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 15px;
}

.section-header h2 {
    font-size: 28px;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 12px;
}

.section-header h2 i {
    color: var(--primary-color);
}

.subtitle {
    color: var(--text-secondary);
    font-size: 14px;
    margin-top: 5px;
}

/* ===== Buttons ===== */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
}

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

.btn-primary:hover {
    background: #1d4ed8;
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn-secondary {
    background: var(--border-color);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: #cbd5e1;
}

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

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

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

/* ===== Stats Grid ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 20px;
    transition: all 0.3s ease;
}

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

.stat-icon {
    width: 60px;
    height: 60px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    color: white;
}

.stat-icon.blue {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
}

.stat-icon.green {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
}

.stat-icon.purple {
    background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
}

.stat-icon.orange {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
}

.stat-info h3 {
    font-size: 32px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 5px;
}

.stat-info p {
    color: var(--text-secondary);
    font-size: 14px;
}

/* ===== Charts ===== */
.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.chart-card {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 24px;
}

.chart-card h3 {
    font-size: 18px;
    color: var(--text-primary);
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.chart-card h3 i {
    color: var(--primary-color);
}

/* ===== Recent Visits ===== */
.recent-visits {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 24px;
}

.recent-visits h3 {
    font-size: 18px;
    color: var(--text-primary);
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.recent-visits h3 i {
    color: var(--primary-color);
}

/* ===== Search Bar ===== */
.search-bar {
    position: relative;
    margin-bottom: 20px;
}

.search-bar i {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
}

.search-bar input {
    width: 100%;
    padding: 12px 16px 12px 45px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 15px;
    transition: all 0.3s ease;
}

.search-bar input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* ===== Filter Bar ===== */
.filter-bar {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.filter-group label {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
}

.filter-group select,
.filter-group input {
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 14px;
}

/* ===== Table ===== */
.table-container {
    overflow-x: auto;
    border: 1px solid var(--border-color);
    border-radius: 12px;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table thead {
    background: var(--light-color);
}

.data-table th {
    padding: 16px;
    text-align: left;
    font-weight: 600;
    color: var(--text-primary);
    border-bottom: 2px solid var(--border-color);
    font-size: 14px;
}

.data-table td {
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-size: 14px;
}

.data-table tbody tr {
    transition: background 0.2s ease;
}

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

.table-actions {
    display: flex;
    gap: 8px;
}

/* ===== Visits Grid ===== */
.visits-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 20px;
}

.visit-card {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.visit-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: var(--primary-color);
}

.visit-card.status-completed::before {
    background: var(--success-color);
}

.visit-card.status-cancelled::before {
    background: var(--danger-color);
}

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

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

.visit-type {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
}

.visit-type.doctor {
    background: #dbeafe;
    color: #1e40af;
}

.visit-type.pharmacy {
    background: #d1fae5;
    color: #065f46;
}

.visit-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
}

.visit-status.scheduled {
    background: #fef3c7;
    color: #92400e;
}

.visit-status.completed {
    background: #d1fae5;
    color: #065f46;
}

.visit-status.cancelled {
    background: #fee2e2;
    color: #991b1b;
}

.visit-name {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 10px;
}

.visit-datetime {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 12px;
}

.visit-datetime i {
    color: var(--primary-color);
}

.visit-objective {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 15px;
    line-height: 1.5;
}

.visit-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

/* ===== Modal ===== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: fadeIn 0.3s ease;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: 16px;
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-xl);
    animation: slideUp 0.3s ease;
}

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

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

.modal-header h3 {
    font-size: 20px;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 10px;
}

.close-btn {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--text-secondary);
    cursor: pointer;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: all 0.2s ease;
}

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

/* ===== Form ===== */
form {
    padding: 24px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

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

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-primary);
    font-size: 14px;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 15px;
    font-family: inherit;
    transition: all 0.3s ease;
}

.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(37, 99, 235, 0.1);
}

.form-group textarea {
    resize: vertical;
}

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

/* ===== Empty State ===== */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}

.empty-state i {
    font-size: 64px;
    color: var(--border-color);
    margin-bottom: 20px;
}

.empty-state h3 {
    font-size: 20px;
    color: var(--text-primary);
    margin-bottom: 10px;
}

.empty-state p {
    font-size: 14px;
}

/* ===== Responsive Design ===== */
@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        gap: 20px;
    }

    .nav-menu {
        width: 100%;
        justify-content: space-between;
    }

    .nav-btn span {
        display: none;
    }

    .nav-btn {
        flex: 1;
        justify-content: center;
        padding: 12px;
    }

    .section-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .charts-grid {
        grid-template-columns: 1fr;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .visits-grid {
        grid-template-columns: 1fr;
    }

    .table-container {
        overflow-x: scroll;
    }
}

@media (max-width: 480px) {
    .section {
        padding: 20px;
    }

    .logo h1 {
        font-size: 18px;
    }

    .section-header h2 {
        font-size: 22px;
    }
}

/* ===== Profile Section ===== */
.profile-container {
    max-width: 800px;
    margin: 0 auto;
}

.profile-card {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    border-radius: 16px;
    padding: 40px;
    text-align: center;
    color: white;
    margin-bottom: 30px;
    box-shadow: var(--shadow-lg);
}

.profile-avatar {
    margin-bottom: 20px;
}

.profile-avatar i {
    font-size: 100px;
    opacity: 0.9;
}

.profile-info h3 {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 10px;
}

.profile-role {
    font-size: 16px;
    opacity: 0.9;
    display: flex;
    align-items: center;
    gap: 8px;
    justify-content: center;
}

.profile-details {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 30px;
    margin-bottom: 20px;
}

.profile-details h3 {
    font-size: 18px;
    color: var(--text-primary);
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.profile-details h3 i {
    color: var(--primary-color);
}

.detail-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 0;
    border-bottom: 1px solid var(--border-color);
}

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

.detail-label {
    font-weight: 500;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.detail-label i {
    width: 20px;
    text-align: center;
    color: var(--primary-color);
}

.detail-value {
    color: var(--text-primary);
    font-weight: 500;
}

.profile-actions {
    display: flex;
    gap: 15px;
    justify-content: center;
}

@media (max-width: 480px) {
    .profile-actions {
        flex-direction: column;
    }
    
    .profile-actions .btn {
        width: 100%;
    }
}

/* ===== Toast Messages ===== */
.toast-message {
    position: fixed;
    top: 20px;
    right: 20px;
    background: white;
    padding: 16px 24px;
    border-radius: 8px;
    box-shadow: var(--shadow-xl);
    display: flex;
    align-items: center;
    gap: 12px;
    transform: translateX(400px);
    transition: transform 0.3s ease;
    z-index: 10000;
    max-width: 350px;
}

.toast-message.show {
    transform: translateX(0);
}

.toast-success {
    border-left: 4px solid var(--success-color);
}

.toast-success i {
    color: var(--success-color);
    font-size: 20px;
}

.toast-error {
    border-left: 4px solid var(--danger-color);
}

.toast-error i {
    color: var(--danger-color);
    font-size: 20px;
}

.toast-message span {
    color: var(--text-primary);
    font-weight: 500;
}