/**
 * PharmAssist Common Styles
 * 
 * Shared CSS for all pages including:
 * - CSS Variables (theme colors)
 * - Header styles
 * - Button styles
 * - Card/container styles
 * - Form styles
 * - Utility classes
 * - Responsive breakpoints
 * - Breadcrumb navigation
 * 
 * Usage:
 * <link rel="stylesheet" href="styles/common.css">
 */

/* ============================================
   CSS VARIABLES - THEME COLORS
   ============================================ */

:root {
    /* Background Colors */
    --bg-primary: #0a0a0a;
    --bg-secondary: #111111;
    --bg-tertiary: #1a1a1a;
    --bg-card: #141414;
    
    /* Border Colors */
    --border-color: #2a2a2a;
    --border-hover: #3a3a3a;
    
    /* Text Colors */
    --text-primary: #ffffff;
    --text-secondary: #a0a0a0;
    --text-muted: #666666;
    
    /* Accent Colors */
    --accent-primary: #00d4ff;      /* Cyan - Primary brand color */
    --accent-secondary: #7c3aed;    /* Purple - Secondary brand color */
    --accent-gradient: linear-gradient(135deg, #00d4ff 0%, #7c3aed 100%);
    
    /* Status Colors */
    --success: #10b981;             /* Green */
    --error: #ef4444;               /* Red */
    --warning: #f59e0b;             /* Orange/Amber */
    --info: #3b82f6;                /* Blue */
    
    /* Effects */
    --shadow-glow: 0 0 40px rgba(0, 212, 255, 0.15);
    --shadow-card: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-elevated: 0 10px 25px rgba(0, 0, 0, 0.2);
    
    /* Transitions */
    --transition-fast: 0.2s ease;
    --transition-normal: 0.3s ease;
}

/* Light Mode Theme */
body.light-mode {
    --bg-primary: #ffffff;
    --bg-secondary: #f9fafb;
    --bg-tertiary: #f3f4f6;
    --bg-card: #ffffff;
    --border-color: #e5e7eb;
    --border-hover: #d1d5db;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --shadow-glow: 0 0 40px rgba(0, 212, 255, 0.1);
    --shadow-card: 0 4px 6px rgba(0, 0, 0, 0.05);
    --shadow-elevated: 0 10px 25px rgba(0, 0, 0, 0.1);
}

/* ============================================
   GLOBAL STYLES
   ============================================ */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg-primary);
    min-height: 100vh;
    color: var(--text-primary);
    padding-top: 70px;
    transition: background var(--transition-normal), color var(--transition-normal);
}

/* ============================================
   HEADER STYLES
   ============================================ */

.header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: var(--bg-secondary);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: 12px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    z-index: 1000;
    border-bottom: 1px solid var(--border-color);
}

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

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

.header-btns {
    display: flex;
    gap: 8px;
    align-items: center;
}

.user-icon { 
    width: 36px; 
    height: 36px; 
    background: var(--accent-gradient); 
    border-radius: 50%; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    font-size: 18px; 
}

.user-name {
    font-weight: 600;
    color: var(--text-primary);
}

.user-role { 
    background: var(--accent-gradient); 
    padding: 4px 12px; 
    border-radius: 12px; 
    font-size: 11px; 
    font-weight: 700; 
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: white;
}

/* ============================================
   BUTTON STYLES
   ============================================ */

.icon-btn {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    width: 44px;
    height: 44px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 18px;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
}

.icon-btn:hover {
    background: var(--border-color);
    border-color: var(--border-hover);
    transform: translateY(-1px);
}

.logout-btn {
    background: var(--error);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
    transition: all var(--transition-fast);
}

.logout-btn:hover {
    background: #dc2626;
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(239, 68, 68, 0.3);
}

.back-btn {
    background: var(--accent-gradient);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
    transition: all var(--transition-fast);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.back-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0, 212, 255, 0.3);
}

.btn {
    background: var(--accent-gradient);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
    transition: all var(--transition-fast);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-elevated);
}

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

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

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

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

.btn-success:hover {
    background: #059669;
}

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

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

/* ============================================
   CARD & CONTAINER STYLES
   ============================================ */

.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
    transition: all var(--transition-fast);
}

.card:hover {
    border-color: var(--border-hover);
    box-shadow: var(--shadow-card);
}

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

.card-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
}

.card-body {
    color: var(--text-secondary);
}

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

/* ============================================
   FORM STYLES
   ============================================ */

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

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

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 14px;
    transition: all var(--transition-fast);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(0, 212, 255, 0.1);
}

.form-textarea {
    resize: vertical;
    min-height: 100px;
}

.form-checkbox {
    width: auto;
    margin-right: 8px;
}

.form-help {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}

.form-error {
    color: var(--error);
    font-size: 12px;
    margin-top: 4px;
}

/* ============================================
   BREADCRUMB NAVIGATION
   ============================================ */

.breadcrumb {
    background: var(--bg-secondary);
    padding: 12px 24px;
    margin-bottom: 20px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.breadcrumb ol {
    list-style: none;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.breadcrumb li {
    display: flex;
    align-items: center;
    color: var(--text-secondary);
    font-size: 14px;
}

.breadcrumb li:not(:last-child)::after {
    content: '›';
    margin-left: 8px;
    color: var(--text-muted);
    font-size: 16px;
}

.breadcrumb a {
    color: var(--accent-primary);
    text-decoration: none;
    transition: color var(--transition-fast);
}

.breadcrumb a:hover {
    color: var(--accent-secondary);
    text-decoration: underline;
}

.breadcrumb li[aria-current="page"] {
    color: var(--text-primary);
    font-weight: 600;
}

/* ============================================
   TABLE STYLES
   ============================================ */

.table-container {
    overflow-x: auto;
    margin-bottom: 20px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-card);
}

.table thead {
    background: var(--bg-tertiary);
}

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

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

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

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

/* ============================================
   UTILITY CLASSES
   ============================================ */

/* Spacing */
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mt-4 { margin-top: 32px; }

.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.mb-4 { margin-bottom: 32px; }

.ml-1 { margin-left: 8px; }
.ml-2 { margin-left: 16px; }
.ml-3 { margin-left: 24px; }
.ml-4 { margin-left: 32px; }

.mr-1 { margin-right: 8px; }
.mr-2 { margin-right: 16px; }
.mr-3 { margin-right: 24px; }
.mr-4 { margin-right: 32px; }

.p-1 { padding: 8px; }
.p-2 { padding: 16px; }
.p-3 { padding: 24px; }
.p-4 { padding: 32px; }

/* Text Alignment */
.text-left { text-align: left; }
.text-center { text-align: center; }
.text-right { text-align: right; }

/* Text Colors */
.text-primary { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-muted { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-error { color: var(--error); }
.text-warning { color: var(--warning); }

/* Font Weights */
.font-normal { font-weight: 400; }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }

/* Display */
.d-none { display: none; }
.d-block { display: block; }
.d-inline { display: inline; }
.d-inline-block { display: inline-block; }
.d-flex { display: flex; }
.d-grid { display: grid; }

/* Flexbox */
.flex-row { flex-direction: row; }
.flex-column { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.justify-start { justify-content: flex-start; }
.justify-center { justify-content: center; }
.justify-end { justify-content: flex-end; }
.justify-between { justify-content: space-between; }
.align-start { align-items: flex-start; }
.align-center { align-items: center; }
.align-end { align-items: flex-end; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }
.gap-3 { gap: 24px; }

/* ============================================
   RESPONSIVE BREAKPOINTS
   ============================================ */

/* Tablet - Max Width 1024px */
@media (max-width: 1024px) {
    .container {
        padding: 16px;
    }

    .header {
        padding: 10px 16px;
    }

    .card {
        padding: 16px;
    }
}

/* Mobile - Max Width 768px */
@media (max-width: 768px) {
    body {
        padding-top: 60px;
    }

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

    .header-left {
        gap: 8px;
    }

    .header-btns {
        gap: 6px;
    }

    .user-icon {
        width: 32px;
        height: 32px;
        font-size: 16px;
    }

    .user-name {
        font-size: 14px;
    }

    .user-role {
        font-size: 10px;
        padding: 3px 8px;
    }

    .icon-btn {
        width: 40px;
        height: 40px;
        font-size: 16px;
    }

    .logout-btn,
    .back-btn,
    .btn {
        padding: 8px 16px;
        font-size: 13px;
    }

    .container {
        padding: 12px;
    }

    .card {
        padding: 12px;
        border-radius: 8px;
    }

    .card-title {
        font-size: 16px;
    }

    /* Make form inputs full width */
    .form-input,
    .form-select,
    .form-textarea {
        font-size: 16px; /* Prevents zoom on iOS */
    }

    /* Tables become scrollable */
    .table-container {
        margin-left: -12px;
        margin-right: -12px;
        border-radius: 0;
        border-left: none;
        border-right: none;
    }

    /* Grid layouts collapse to single column */
    .grid-2,
    .grid-3,
    .grid-4 {
        grid-template-columns: 1fr !important;
    }

    /* Breadcrumb */
    .breadcrumb {
        padding: 8px 12px;
    }

    .breadcrumb li {
        font-size: 13px;
    }

    /* Hide less critical header elements on very small screens */
    @media (max-width: 480px) {
        .header {
            gap: 8px;
        }

        .header-left {
            flex: 1;
            min-width: 0;
        }

        .user-name {
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
            max-width: 120px;
        }

        .logout-btn span {
            display: none;
        }

        .logout-btn::before {
            content: '🚪';
        }
    }
}

/* Small Mobile - Max Width 480px */
@media (max-width: 480px) {
    .header {
        padding: 8px;
    }

    .container {
        padding: 8px;
    }

    .card {
        padding: 10px;
    }

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

    /* Ensure touch targets are at least 44x44px */
    button,
    .btn,
    .icon-btn,
    a[role="button"] {
        min-height: 44px;
        min-width: 44px;
    }

    /* Stack header buttons vertically if needed */
    .header-btns {
        flex-wrap: wrap;
    }
}

/* ============================================
   MODAL / DIALOG STYLES
   ============================================ */

.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    padding: 16px;
}

.modal-content {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 24px;
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-elevated);
}

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

.modal-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-secondary);
    transition: color var(--transition-fast);
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

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

.modal-body {
    color: var(--text-secondary);
}

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

@media (max-width: 768px) {
    .modal {
        padding: 8px;
    }

    .modal-content {
        padding: 16px;
        max-height: 95vh;
    }

    .modal-title {
        font-size: 18px;
    }

    .modal-footer {
        flex-direction: column;
    }

    .modal-footer .btn {
        width: 100%;
    }
}

/* ============================================
   ACCESSIBILITY
   ============================================ */

/* Focus styles for keyboard navigation */
*:focus-visible {
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
}

/* Screen reader only text */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* Skip to main content link */
.skip-to-main {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--accent-primary);
    color: white;
    padding: 8px 16px;
    text-decoration: none;
    z-index: 10000;
}

.skip-to-main:focus {
    top: 0;
}
