/* PhoneStock SaaS - Main Stylesheet */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #2563eb;
    --secondary-color: #1e40af;
    --success-color: #059669;
    --danger-color: #dc2626;
    --warning-color: #d97706;
    --info-color: #0891b2;
    --dark-color: #1f2937;
    --light-color: #f3f4f6;
    --white: #ffffff;
    --border-color: #e5e7eb;
    --text-color: #374151;
    --sidebar-width: 260px;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--light-color);
    color: var(--text-color);
    line-height: 1.6;
}

/* Login Page */
.login-page {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-container {
    width: 100%;
    max-width: 450px;
    padding: 20px;
}

.login-box {
    background: var(--white);
    padding: 40px;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

.login-header {
    text-align: center;
    margin-bottom: 30px;
}

.login-header h1 {
    color: var(--primary-color);
    font-size: 28px;
    margin-bottom: 10px;
}

.login-header p {
    color: var(--text-color);
    font-size: 16px;
}

.login-footer {
    text-align: center;
    margin-top: 30px;
}

.login-footer p {
    margin: 10px 0;
    font-size: 14px;
}

/* Forms */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--dark-color);
}

.form-control {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 15px;
    transition: all 0.3s;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

select.form-control {
    cursor: pointer;
}

textarea.form-control {
    resize: vertical;
    min-height: 100px;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    text-decoration: none;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-primary {
    background: var(--primary-color);
    color: var(--white);
}

.btn-primary:hover {
    background: var(--secondary-color);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(37, 99, 235, 0.3);
}

.btn-success {
    background: var(--success-color);
    color: var(--white);
}

.btn-danger {
    background: var(--danger-color);
    color: var(--white);
}

.btn-warning {
    background: var(--warning-color);
    color: var(--white);
}

.btn-secondary {
    background: #6b7280;
    color: var(--white);
}

.btn-block {
    width: 100%;
    display: block;
}

.btn-sm {
    padding: 8px 16px;
    font-size: 14px;
}

/* Alerts */
.alert {
    padding: 15px 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    border-left: 4px solid;
}

.alert-success {
    background: #d1fae5;
    color: #065f46;
    border-color: var(--success-color);
}

.alert-danger {
    background: #fee2e2;
    color: #991b1b;
    border-color: var(--danger-color);
}

.alert-warning {
    background: #fef3c7;
    color: #92400e;
    border-color: var(--warning-color);
}

.alert-info {
    background: #cffafe;
    color: #155e75;
    border-color: var(--info-color);
}

/* Dashboard Layout */
.dashboard-wrapper {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--dark-color);
    color: var(--white);
    position: fixed;
    height: 100vh;
    overflow-y: auto;
    z-index: 1000;
}

.sidebar-header {
    padding: 25px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-header h2 {
    font-size: 20px;
    margin-bottom: 5px;
}

.sidebar-header p {
    font-size: 14px;
    color: #9ca3af;
}

.sidebar-menu {
    list-style: none;
    padding: 0;
    margin: 20px 0;
}

.sidebar-menu li {
    margin-bottom: 5px;
}

.sidebar-menu a {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    color: #d1d5db;
    text-decoration: none;
    transition: all 0.3s;
}

.sidebar-menu a:hover,
.sidebar-menu a.active {
    background: var(--primary-color);
    color: var(--white);
}

.sidebar-menu .icon {
    margin-left: 12px;
    font-size: 18px;
}

/* Main Content */
.main-content {
    margin-right: var(--sidebar-width);
    width: calc(100% - var(--sidebar-width));
    min-height: 100vh;
}

/* Top Bar */
.top-bar {
    background: var(--white);
    padding: 20px 30px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
}

.page-title h1 {
    font-size: 24px;
    color: var(--dark-color);
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 20px;
}

.user-info {
    text-align: left;
}

.user-info strong {
    display: block;
    color: var(--dark-color);
}

.user-info small {
    color: #6b7280;
}

/* Content Area */
.content-area {
    padding: 30px;
}

/* Cards */
.card {
    background: var(--white);
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    margin-bottom: 30px;
}

.card-header {
    padding: 20px 25px;
    border-bottom: 1px solid var(--border-color);
}

.card-header h3 {
    font-size: 18px;
    color: var(--dark-color);
}

.card-body {
    padding: 25px;
}

.card-footer {
    padding: 15px 25px;
    border-top: 1px solid var(--border-color);
    background: #f9fafb;
}

/* Stats Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: var(--white);
    padding: 25px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    gap: 20px;
}

.stat-icon {
    width: 60px;
    height: 60px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: var(--white);
}

.stat-icon.primary {
    background: var(--primary-color);
}

.stat-icon.success {
    background: var(--success-color);
}

.stat-icon.danger {
    background: var(--danger-color);
}

.stat-icon.warning {
    background: var(--warning-color);
}

.stat-details h4 {
    font-size: 14px;
    color: #6b7280;
    margin-bottom: 5px;
}

.stat-details .stat-value {
    font-size: 28px;
    font-weight: bold;
    color: var(--dark-color);
}

/* Tables */
.table-responsive {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

table thead {
    background: #f9fafb;
}

table th {
    padding: 15px;
    text-align: right;
    font-weight: 600;
    color: var(--dark-color);
    border-bottom: 2px solid var(--border-color);
}

table td {
    padding: 15px;
    border-bottom: 1px solid var(--border-color);
}

table tbody tr:hover {
    background: #f9fafb;
}

/* Badges */
.badge {
    display: inline-block;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
}

.badge-success {
    background: #d1fae5;
    color: #065f46;
}

.badge-danger {
    background: #fee2e2;
    color: #991b1b;
}

.badge-warning {
    background: #fef3c7;
    color: #92400e;
}

.badge-info {
    background: #cffafe;
    color: #155e75;
}

.badge-secondary {
    background: #e5e7eb;
    color: #4b5563;
}

/* Utilities */
.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

.text-left {
    text-align: left;
}

.text-muted {
    color: #6b7280;
}

.mt-1 { margin-top: 10px; }
.mt-2 { margin-top: 20px; }
.mt-3 { margin-top: 30px; }
.mb-1 { margin-bottom: 10px; }
.mb-2 { margin-bottom: 20px; }
.mb-3 { margin-bottom: 30px; }

.d-flex {
    display: flex;
}

.justify-between {
    justify-content: space-between;
}

.align-center {
    align-items: center;
}

.gap-2 {
    gap: 20px;
}

/* ========================================
   ADDITIONAL RESPONSIVE UTILITIES
   ======================================== */

/* Flex helpers */
.flex-wrap {
    flex-wrap: wrap;
}

.flex-column {
    flex-direction: column;
}

/* Grid helpers */
.grid-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
}

.grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}

.grid-4 {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
}

/* Responsive grids */
@media (max-width: 768px) {
    .grid-2,
    .grid-3,
    .grid-4 {
        grid-template-columns: 1fr;
        gap: 15px;
    }
}

@media (min-width: 769px) and (max-width: 992px) {
    .grid-3,
    .grid-4 {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Image responsive */
img {
    max-width: 100%;
    height: auto;
}

/* Product Image Container */
.product-image {
    width: 100%;
    height: 200px;
    object-fit: cover;
    border-radius: 8px;
}

@media (max-width: 480px) {
    .product-image {
        height: 150px;
    }
}

/* Action buttons container */
.action-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

@media (max-width: 480px) {
    .action-buttons {
        flex-direction: column;
    }
    
    .action-buttons .btn {
        width: 100%;
    }
}

/* Search and filter section */
.search-filter-section {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.search-filter-section .form-control {
    flex: 1;
    min-width: 200px;
}

@media (max-width: 768px) {
    .search-filter-section {
        flex-direction: column;
    }
    
    .search-filter-section .form-control {
        width: 100%;
        min-width: 100%;
    }
}

/* Progress bar responsive */
.progress-bar {
    height: 25px;
    border-radius: 8px;
}

@media (max-width: 480px) {
    .progress-bar {
        height: 20px;
        font-size: 12px;
    }
}

/* Info boxes */
.info-box {
    background: var(--light-color);
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
}

@media (max-width: 480px) {
    .info-box {
        padding: 12px;
        font-size: 13px;
    }
}

/* Hide on mobile */
.hide-mobile {
    display: block;
}

@media (max-width: 768px) {
    .hide-mobile {
        display: none !important;
    }
}

/* Show only on mobile */
.show-mobile {
    display: none;
}

@media (max-width: 768px) {
    .show-mobile {
        display: block !important;
    }
}

/* Overflow scroll hint */
.scroll-hint {
    position: relative;
}

.scroll-hint::after {
    content: '⟵ مرر للمزيد';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(37, 99, 235, 0.9);
    color: white;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 12px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s;
}

@media (max-width: 768px) {
    .scroll-hint:hover::after {
        opacity: 1;
    }
}

/* Mobile Menu Toggle */
.mobile-menu-toggle {
    display: none;
    background: var(--primary-color);
    color: var(--white);
    border: none;
    padding: 10px 15px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 20px;
    position: fixed;
    top: 15px;
    right: 15px;
    z-index: 1001;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
}

/* ========================================
   RESPONSIVE DESIGN - Mobile First Approach
   ======================================== */

/* Tablets and below (768px) */
@media (max-width: 768px) {
    /* Mobile Menu */
    .mobile-menu-toggle {
        display: block;
    }
    
    .sidebar {
        transform: translateX(100%);
        transition: transform 0.3s ease;
        box-shadow: -5px 0 15px rgba(0, 0, 0, 0.3);
    }
    
    .sidebar.active {
        transform: translateX(0);
    }
    
    .sidebar-overlay.active {
        display: block;
    }

    .main-content {
        margin-right: 0;
        width: 100%;
    }

    /* Stats Grid */
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    /* Top Bar */
    .top-bar {
        flex-direction: column;
        gap: 15px;
        padding: 60px 20px 20px;
    }
    
    .page-title h1 {
        font-size: 20px;
    }
    
    .user-menu {
        width: 100%;
        justify-content: space-between;
        flex-wrap: wrap;
    }
    
    .user-info {
        flex: 1;
    }

    /* Content Area */
    .content-area {
        padding: 20px 15px;
    }

    /* Cards */
    .card {
        border-radius: 8px;
    }
    
    .card-header {
        padding: 15px;
        display: flex;
        flex-direction: column;
        gap: 10px;
    }
    
    .card-header h3 {
        font-size: 16px;
    }
    
    .card-header .btn {
        width: 100%;
    }
    
    .card-body {
        padding: 15px;
    }
    
    .card-footer {
        padding: 15px;
    }

    /* Stat Cards */
    .stat-card {
        padding: 20px 15px;
    }
    
    .stat-icon {
        width: 50px;
        height: 50px;
        font-size: 20px;
    }
    
    .stat-details h4 {
        font-size: 13px;
    }
    
    .stat-details .stat-value {
        font-size: 22px;
    }

    /* Tables */
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        border-radius: 8px;
        margin: 0 -15px;
        padding: 0 15px;
    }
    
    table {
        min-width: 700px;
        font-size: 13px;
    }
    
    table th, table td {
        padding: 10px 8px;
        font-size: 13px;
        white-space: nowrap;
    }
    
    table th:first-child,
    table td:first-child {
        position: sticky;
        right: 0;
        background: white;
        z-index: 10;
    }
    
    table thead th:first-child {
        background: #f9fafb;
    }

    /* Forms */
    .form-group {
        margin-bottom: 15px;
    }
    
    .form-control {
        padding: 10px 12px;
        font-size: 14px;
    }
    
    /* Form rows - stack on mobile */
    .form-row {
        display: flex;
        flex-direction: column;
        gap: 15px;
    }

    /* Buttons */
    .btn {
        padding: 10px 20px;
        font-size: 14px;
        width: 100%;
        margin-bottom: 10px;
    }
    
    .btn:last-child {
        margin-bottom: 0;
    }
    
    .btn-sm {
        padding: 8px 16px;
        font-size: 13px;
        width: auto;
        margin-bottom: 0;
    }
    
    /* Button groups */
    .d-flex .btn {
        width: auto;
        flex: 1;
    }

    /* Login */
    .login-box {
        padding: 30px 20px;
    }
    
    .login-header h1 {
        font-size: 24px;
    }

    /* Alerts */
    .alert {
        padding: 12px 15px;
        font-size: 14px;
        margin: 0 -15px 20px;
        border-radius: 0;
    }
    
    /* POS Specific */
    .pos-container {
        flex-direction: column !important;
    }
    
    .pos-products {
        width: 100% !important;
        margin-bottom: 20px;
    }
    
    .pos-cart {
        width: 100% !important;
        position: relative !important;
        height: auto !important;
    }
    
    .product-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 10px !important;
    }
    
    .product-card {
        padding: 10px !important;
    }
    
    .product-card img {
        height: 100px !important;
    }
    
    .product-card h4 {
        font-size: 13px !important;
    }
    
    .product-card .price {
        font-size: 14px !important;
    }
    
    /* Modal Responsive */
    .modal-content {
        margin: 10px;
        max-height: 90vh;
        overflow-y: auto;
    }
    
    .modal-header, .modal-body, .modal-footer {
        padding: 15px;
    }
}

/* Small Mobile (480px) */
@media (max-width: 480px) {
    /* Top Bar */
    .top-bar {
        padding: 60px 10px 15px;
    }
    
    .page-title h1 {
        font-size: 18px;
    }

    /* Content Area */
    .content-area {
        padding: 15px 10px;
    }

    /* Stats Grid */
    .stats-grid {
        gap: 10px;
    }
    
    .stat-card {
        padding: 15px 10px;
        flex-direction: column;
        text-align: center;
        gap: 10px;
    }
    
    .stat-icon {
        width: 45px;
        height: 45px;
        font-size: 18px;
        margin: 0 auto;
    }
    
    .stat-details h4 {
        font-size: 12px;
    }
    
    .stat-details .stat-value {
        font-size: 20px;
    }

    /* Cards */
    .card {
        margin-bottom: 15px;
        border-radius: 8px;
    }
    
    .card-header {
        padding: 12px 10px;
    }
    
    .card-header h3 {
        font-size: 15px;
    }
    
    .card-body {
        padding: 12px 10px;
    }
    
    .card-footer {
        padding: 12px 10px;
    }

    /* Forms */
    .form-group {
        margin-bottom: 12px;
    }
    
    .form-group label {
        font-size: 13px;
        margin-bottom: 6px;
    }
    
    .form-control {
        padding: 9px 10px;
        font-size: 13px;
    }

    /* Buttons */
    .btn {
        padding: 9px 16px;
        font-size: 13px;
    }
    
    .btn-sm {
        padding: 6px 12px;
        font-size: 12px;
    }

    /* Tables */
    table {
        font-size: 12px;
        min-width: 600px;
    }
    
    table th, table td {
        padding: 8px 6px;
    }

    /* Badges */
    .badge {
        padding: 4px 8px;
        font-size: 11px;
    }

    /* Login */
    .login-container {
        padding: 10px;
    }
    
    .login-box {
        padding: 25px 15px;
    }
    
    .login-header h1 {
        font-size: 20px;
    }
    
    .login-header p {
        font-size: 13px;
    }

    /* User Menu */
    .user-menu {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
        width: 100%;
    }
    
    .user-menu .btn {
        width: 100%;
    }
    
    /* Sidebar */
    .sidebar-header {
        padding: 20px 15px;
    }
    
    .sidebar-header h2 {
        font-size: 18px;
    }
    
    .sidebar-menu a {
        padding: 12px 15px;
        font-size: 14px;
    }
    
    /* POS Mobile Optimization */
    .product-grid {
        grid-template-columns: 1fr !important;
    }
    
    .product-card {
        padding: 12px !important;
    }
    
    .product-card img {
        height: 120px !important;
    }
    
    /* Cart Items */
    .cart-item {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 10px;
    }
    
    /* Search Box */
    .search-box input {
        font-size: 13px;
        padding: 10px;
    }
    
    /* Modal */
    .modal-content {
        margin: 5px;
    }
    
    .modal-header h3 {
        font-size: 16px;
    }
    
    /* Alerts */
    .alert {
        font-size: 13px;
        padding: 10px 12px;
    }
}

/* Large Tablets (992px) */
@media (min-width: 769px) and (max-width: 992px) {
    :root {
        --sidebar-width: 220px;
    }
    
    .sidebar {
        width: 220px;
    }
    
    .sidebar-header {
        padding: 20px 15px;
    }
    
    .sidebar-header h2 {
        font-size: 18px;
    }
    
    .sidebar-menu a {
        padding: 10px 15px;
        font-size: 14px;
    }
    
    .sidebar-menu .icon {
        font-size: 16px;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 15px;
    }
    
    .content-area {
        padding: 25px 20px;
    }
    
    .top-bar {
        padding: 15px 20px;
    }
    
    .page-title h1 {
        font-size: 22px;
    }
}

/* Extra Large Screens (1400px+) */
@media (min-width: 1400px) {
    .content-area {
        max-width: 1600px;
        margin: 0 auto;
        padding: 40px 50px;
    }
    
    .stats-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 25px;
    }
    
    .stat-card {
        padding: 30px;
    }
    
    .card-header {
        padding: 25px 30px;
    }
    
    .card-body {
        padding: 30px;
    }
}

/* Landscape Mode Optimization */
@media (max-height: 600px) and (orientation: landscape) {
    .sidebar {
        overflow-y: auto;
    }
    
    .sidebar-header {
        padding: 15px;
    }
    
    .sidebar-menu a {
        padding: 8px 15px;
        font-size: 13px;
    }
    
    .top-bar {
        padding: 10px 20px;
    }
    
    .content-area {
        padding: 15px 20px;
    }
}

/* Print Styles */
@media print {
    .sidebar,
    .top-bar,
    .mobile-menu-toggle,
    .btn,
    .sidebar-overlay {
        display: none !important;
    }
    
    .main-content {
        margin-right: 0;
        width: 100%;
    }
    
    .card {
        box-shadow: none;
        border: 1px solid #ddd;
    }
}
