/* Optical Shop POS System - Main Stylesheet */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Noto+Sans+Sinhala:wght@400;500;600;700&display=swap');

:root {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-card: #1e293b;
    --bg-card-hover: #334155;
    --border-color: #334155;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --primary: #0ea5e9;
    --primary-hover: #0284c7;
    --primary-glow: rgba(14, 165, 233, 0.25);
    --accent: #10b981;
    --accent-hover: #059669;
    --warning: #f59e0b;
    --danger: #ef4444;
    --purple: #8b5cf6;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --shadow-sm: 0 2px 8px rgba(0,0,0,0.2);
    --shadow-md: 0 4px 20px rgba(0,0,0,0.3);
    --shadow-lg: 0 10px 30px rgba(0,0,0,0.4);
    --font-family: 'Inter', 'Noto Sans Sinhala', system-ui, -apple-system, sans-serif;
}

[data-theme="light"] {
    --bg-primary: #f1f5f9;
    --bg-secondary: #ffffff;
    --bg-card: #ffffff;
    --bg-card-hover: #f8fafc;
    --border-color: #e2e8f0;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --primary: #0284c7;
    --primary-hover: #0369a1;
    --primary-glow: rgba(2, 132, 199, 0.15);
    --shadow-sm: 0 2px 8px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 20px rgba(0,0,0,0.08);
    --shadow-lg: 0 10px 30px rgba(0,0,0,0.12);
}

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

body {
    font-family: var(--font-family);
    background-color: var(--bg-primary);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    overflow-x: hidden;
}

/* App Container Layout */
#app {
    display: flex;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
}

/* Sidebar Styling */
.sidebar {
    width: 260px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 1.25rem 1rem;
    transition: all 0.3s ease;
    z-index: 10;
}

.brand-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding-bottom: 1.25rem;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 1.5rem;
}

.brand-logo {
    width: 42px;
    height: 42px;
    background: linear-gradient(135deg, var(--primary), var(--purple));
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 1.4rem;
    box-shadow: 0 4px 12px var(--primary-glow);
}

.brand-title h1 {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-main);
    line-height: 1.2;
}

.brand-title span {
    font-size: 0.75rem;
    color: var(--primary);
    font-weight: 600;
}

.nav-menu {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    list-style: none;
    flex: 1;
}

.nav-item button {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.75rem 1rem;
    background: transparent;
    border: none;
    border-radius: var(--radius-md);
    color: var(--text-muted);
    font-family: inherit;
    font-size: 0.92rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
}

.nav-item button i {
    font-size: 1.15rem;
    width: 22px;
}

.nav-item button:hover {
    background: var(--bg-card-hover);
    color: var(--text-main);

}

.nav-item.active button {
    background: linear-gradient(90deg, rgba(14, 165, 233, 0.15), transparent);
    border-left: 4px solid var(--primary);
    color: var(--primary);
    font-weight: 600;
}

.sidebar-footer {
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.shop-status-badge {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
    color: var(--accent);
    background: rgba(16, 185, 129, 0.1);
    padding: 0.4rem 0.75rem;
    border-radius: 20px;
}

.status-dot {
    width: 8px;
    height: 8px;
    background: var(--accent);
    border-radius: 50%;
    box-shadow: 0 0 8px var(--accent);
}

/* Main Content Wrapper */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow-y: auto;
    background: var(--bg-primary);
}

.top-bar {
    height: 64px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 5;
}

.top-bar-title {
    font-size: 1.25rem;
    font-weight: 700;
}

.top-bar-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.btn-icon {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

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

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-hover));
    color: #ffffff;
    border: none;
    padding: 0.6rem 1.25rem;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-family: inherit;
    font-size: 0.9rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    box-shadow: 0 4px 14px var(--primary-glow);
    transition: all 0.2s ease;
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 18px var(--primary-glow);
}

.btn-secondary {
    background: var(--bg-card);
    color: var(--text-main);
    border: 1px solid var(--border-color);
    padding: 0.6rem 1.25rem;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-family: inherit;
    font-size: 0.9rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.2s ease;
}

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

.btn-success {
    background: linear-gradient(135deg, var(--accent), var(--accent-hover));
    color: #fff;
    border: none;
    padding: 0.6rem 1.25rem;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-family: inherit;
    font-size: 0.9rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    box-shadow: 0 4px 14px rgba(16, 185, 129, 0.25);
}

.btn-success:hover {
    transform: translateY(-1px);
}

/* Page Views Container */
.page-container {
    padding: 1.5rem;
    flex: 1;
}

.page-view {
    display: none;
}

.page-view.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

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

/* Dashboard Summary Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.25rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    display: flex;
    align-items: center;
    gap: 1.25rem;
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s ease;
}

.stat-card:hover {
    transform: translateY(-3px);
}

.stat-icon {
    width: 52px;
    height: 52px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.stat-icon.primary { background: rgba(14, 165, 233, 0.15); color: var(--primary); }
.stat-icon.warning { background: rgba(245, 158, 11, 0.15); color: var(--warning); }
.stat-icon.success { background: rgba(16, 185, 129, 0.15); color: var(--accent); }
.stat-icon.purple { background: rgba(139, 92, 246, 0.15); color: var(--purple); }

.stat-info h4 {
    font-size: 0.82rem;
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-info .value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-main);
    margin-top: 0.2rem;
}

/* POS New Order Layout */
.pos-layout {
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 1.5rem;
}

@media (max-width: 1200px) {
    .pos-layout {
        grid-template-columns: 1fr;
    }
}

.card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-sm);
}

.card-title {
    font-size: 1.05rem;
    font-weight: 700;
    margin-bottom: 1.2rem;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    color: var(--text-main);
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.75rem;
}

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

/* Form Styles */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.form-group label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
}

.form-control {
    width: 100%;
    padding: 0.65rem 0.85rem;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-main);
    font-family: inherit;
    font-size: 0.92rem;
    outline: none;
    transition: border-color 0.2s ease;
}

.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

/* Prescription Grid Table */
.prescription-container {
    overflow-x: auto;
}

.prescription-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 0.5rem;
}

.prescription-table th {
    background: var(--bg-primary);
    color: var(--text-muted);
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    padding: 0.6rem;
    border: 1px solid var(--border-color);
    text-align: center;
}

.prescription-table td {
    padding: 0.4rem;
    border: 1px solid var(--border-color);
}

.eye-label {
    font-weight: 700;
    text-align: center;
    font-size: 0.9rem;
    background: var(--bg-primary);
}

.eye-label.right { color: var(--primary); }
.eye-label.left { color: var(--purple); }

.prescription-table input {
    width: 100%;
    text-align: center;
    padding: 0.5rem 0.2rem;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    color: var(--text-main);
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 600;
}

.prescription-table input:focus {
    background: var(--bg-primary);
    border-color: var(--primary);
    outline: none;
}

/* Order Summary Side Panel */
.order-summary-card {
    position: sticky;
    top: 80px;
}

.summary-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.6rem 0;
    border-bottom: 1px dashed var(--border-color);
    font-size: 0.92rem;
}

.summary-row.total {
    border-bottom: none;
    padding-top: 1rem;
    font-size: 1.15rem;
    font-weight: 700;
}

.summary-row.balance {
    background: rgba(239, 68, 68, 0.1);
    padding: 0.75rem;
    border-radius: var(--radius-md);
    color: var(--danger);
    font-weight: 700;
    margin-top: 0.5rem;
    border-bottom: none;
}

.summary-row.balance.cleared {
    background: rgba(16, 185, 129, 0.1);
    color: var(--accent);
}

/* Table Design for Orders & Stock */
.data-table-container {
    overflow-x: auto;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 0.9rem;
}

.data-table th {
    background: var(--bg-primary);
    color: var(--text-muted);
    font-weight: 600;
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

.data-table td {
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-main);
    vertical-align: middle;
}

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

/* Status Badges */
.badge {
    padding: 0.35rem 0.75rem;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.badge-placed { background: rgba(14, 165, 233, 0.15); color: var(--primary); }
.badge-processing { background: rgba(245, 158, 11, 0.15); color: var(--warning); }
.badge-ready { background: rgba(139, 92, 246, 0.15); color: var(--purple); }
.badge-delivered { background: rgba(16, 185, 129, 0.15); color: var(--accent); }

/* Modal Box */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.modal-backdrop.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 650px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    transform: scale(0.95);
    transition: transform 0.3s ease;
}

.modal-backdrop.active .modal-card {
    transform: scale(1);
}

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

.modal-header h3 {
    font-size: 1.15rem;
    font-weight: 700;
}

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.75rem;
}

/* SMS Preview Alert Box */
.sms-preview-box {
    background: #064e3b;
    color: #a7f3d0;
    border: 1px solid #059669;
    border-radius: var(--radius-md);
    padding: 1rem;
    font-family: monospace;
    font-size: 0.88rem;
    margin-top: 0.75rem;
    white-space: pre-wrap;
    line-height: 1.4;
}

/* Notification Toast */
.toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 200;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toast {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 0.85rem 1.25rem;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.9rem;
    font-weight: 500;
    animation: slideUp 0.3s ease;
}

.toast.success i { color: var(--accent); }
.toast.info i { color: var(--primary); }
.toast.warning i { color: var(--warning); }

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

/* Mobile Responsive Utility Styles */
.mobile-only {
    display: none !important;
}

.sidebar-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 90;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.sidebar-backdrop.active {
    opacity: 1;
    pointer-events: auto;
}

/* Responsive Media Queries */
@media (max-width: 991px) {
    .mobile-only {
        display: flex !important;
    }

    #app {
        flex-direction: column;
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: -280px;
        height: 100vh;
        width: 270px;
        z-index: 100;
        box-shadow: var(--shadow-lg);
        transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .sidebar.mobile-open {
        left: 0;
    }

    .top-bar {
        padding: 0 1rem;
    }

    .top-bar-title {
        font-size: 1rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 220px;
    }

    .page-container {
        padding: 1rem;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }

    .stat-card {
        padding: 1rem;
        gap: 0.75rem;
    }

    .stat-icon {
        width: 44px;
        height: 44px;
        font-size: 1.25rem;
    }

    .stat-info .value {
        font-size: 1.2rem;
    }
}

@media (max-width: 767px) {
    .form-grid {
        grid-template-columns: 1fr;
    }

    .pos-layout {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .card {
        padding: 1rem;
        border-radius: var(--radius-md);
        margin-bottom: 1rem;
    }

    .card-title {
        font-size: 0.95rem;
        margin-bottom: 0.85rem;
    }

    .prescription-table th,
    .prescription-table td {
        padding: 0.35rem 0.2rem;
        font-size: 0.75rem;
    }

    .prescription-table input {
        font-size: 0.85rem;
        padding: 0.4rem 0.1rem;
        min-width: 50px;
    }

    .data-table th,
    .data-table td {
        padding: 0.65rem 0.5rem;
        font-size: 0.8rem;
    }

    .modal-card {
        width: 95%;
        max-width: 95vw;
        border-radius: var(--radius-md);
    }

    .modal-header, .modal-body, .modal-footer {
        padding: 1rem;
    }

    .toast-container {
        left: 10px;
        right: 10px;
        bottom: 15px;
    }

    .toast {
        font-size: 0.82rem;
        padding: 0.75rem 1rem;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .top-bar-title {
        max-width: 160px;
        font-size: 0.9rem;
    }

    .btn-primary, .btn-secondary, .btn-success {
        padding: 0.55rem 0.9rem;
        font-size: 0.82rem;
    }

    .prescription-table {
        min-width: 460px;
    }
}
