/* Global Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
}

/* Container */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

/* Dashboard Layout */
.dashboard {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 260px;
    background: white;
    box-shadow: 2px 0 10px rgba(0,0,0,0.1);
    position: fixed;
    height: 100vh;
    overflow-y: auto;
}

.sidebar-header {
    padding: 25px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.sidebar-header h2 {
    font-size: 18px;
    margin-bottom: 5px;
}

.sidebar-header p {
    font-size: 13px;
    opacity: 0.9;
}

.sidebar-menu {
    padding: 15px 0;
}

.menu-section {
    margin-bottom: 20px;
}

.menu-section-title {
    padding: 10px 20px;
    font-size: 12px;
    font-weight: 600;
    color: #999;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.menu-item {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    color: #555;
    text-decoration: none;
    transition: all 0.3s ease;
}

.menu-item:hover {
    background: #f5f5f5;
    color: #667eea;
}

.menu-item.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-right: 3px solid #764ba2;
}

.menu-item i {
    margin-right: 12px;
    font-size: 18px;
    width: 20px;
    text-align: center;
}

.main-content {
    margin-left: 220px;
    flex: 1;
    padding: 30px;
}

/* Header */
.header {
    background: white;
    padding: 20px 30px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    margin-bottom: 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header h1 {
    font-size: 28px;
    color: #333;
}

.header-actions {
    display: flex;
    gap: 15px;
    align-items: center;
}

/* PWA Install Button */
.pwa-header-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.pwa-header-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.pwa-header-btn.installed {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    cursor: default;
}

.pwa-header-btn.installed:hover {
    transform: none;
}

.pwa-header-btn:disabled {
    opacity: 0.8;
    cursor: default;
}

/* Cards */
.card {
    background: white;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    padding: 25px;
    margin-bottom: 25px;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid #f0f0f0;
}

.card-header h2 {
    font-size: 20px;
    color: #333;
}

.card-body {
    padding: 10px 0;
}

/* Stats Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: white;
    border-radius: 10px;
    padding: 25px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.stat-info h3 {
    font-size: 14px;
    color: #999;
    font-weight: 500;
    margin-bottom: 8px;
}

.stat-info p {
    font-size: 32px;
    font-weight: bold;
    color: #333;
}

.stat-icon {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
}

.stat-icon.blue { background: #e3f2fd; color: #2196f3; }
.stat-icon.green { background: #e8f5e9; color: #4caf50; }
.stat-icon.orange { background: #fff3e0; color: #ff9800; }
.stat-icon.purple { background: #f3e5f5; color: #9c27b0; }

/* Forms */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #555;
    font-size: 14px;
}

/* Radio Button Group Styles */
.radio-group {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    margin-top: 8px;
}

.radio-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 10px 16px;
    border: 2px solid #ddd;
    border-radius: 8px;
    background: #f9f9f9;
    transition: all 0.3s ease;
    font-weight: 500;
    min-width: 80px;
    justify-content: center;
}

.radio-label:hover {
    border-color: #667eea;
    background: #f0f4ff;
}

.radio-label input[type="radio"] {
    width: 18px;
    height: 18px;
    margin: 0;
    cursor: pointer;
    accent-color: #667eea;
}

.radio-label input[type="radio"]:checked + span,
.radio-label:has(input[type="radio"]:checked) {
    color: #667eea;
}

.radio-label:has(input[type="radio"]:checked) {
    border-color: #667eea;
    background: #e8eeff;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.2);
}

.form-control,
input[type="text"],
input[type="password"],
input[type="email"],
input[type="tel"],
input[type="number"],
select,
textarea {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 14px;
    font-family: inherit;
    transition: all 0.3s ease;
    background: white;
}

input[type="text"]:focus,
input[type="password"]:focus,
input[type="email"]:focus,
input[type="tel"]:focus,
input[type="number"]:focus,
select:focus,
textarea:focus,
.form-control:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

input[type="text"]:disabled,
input[type="password"]:disabled,
input[type="email"]:disabled,
select:disabled,
textarea:disabled,
.form-control:disabled {
    background: #f5f5f5;
    cursor: not-allowed;
    opacity: 0.7;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
}

.form-section {
    background: #f9f9f9;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.form-section h3 {
    font-size: 16px;
    color: #667eea;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid #667eea;
}

/* Buttons */
.btn,
button[type="submit"],
button[type="button"] {
    padding: 12px 25px;
    border: none;
    border-radius: 5px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-block;
    font-family: inherit;
}

.btn-block,
button[type="submit"] {
    width: 100%;
    display: block;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.btn-success {
    background: #4caf50;
    color: white;
}

.btn-success:hover {
    background: #45a049;
    transform: translateY(-2px);
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #5a6268;
}

.btn-danger {
    background: #f44336;
    color: white;
}

.btn-danger:hover {
    background: #da190b;
}

.btn-info {
    background: #17a2b8;
    color: white;
}

.btn-info:hover {
    background: #138496;
}

.btn-warning {
    background: #ff9800;
    color: white;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

.btn-group {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

/* Tables */
.table-responsive {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

table thead {
    background: #f5f5f5;
}

table th {
    padding: 12px 15px;
    text-align: left;
    font-weight: 600;
    color: #555;
    font-size: 13px;
    border-bottom: 2px solid #ddd;
}

table td {
    padding: 12px 15px;
    border-bottom: 1px solid #f0f0f0;
    font-size: 14px;
}

table tbody tr:hover {
    background: #f9f9f9;
}

.table-input {
    width: 80px;
    padding: 8px 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    text-align: center;
}

.table-total {
    background: #f5f5f5;
    font-weight: 600;
}

/* Badges */
.badge {
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
}

.badge-success { background: #4caf50; color: white; }
.badge-warning { background: #ff9800; color: white; }
.badge-danger { background: #f44336; color: white; }
.badge-info { background: #2196f3; color: white; }
.badge-secondary { background: #6c757d; color: white; }

/* Alerts */
.alert {
    padding: 15px 20px;
    border-radius: 5px;
    margin-bottom: 20px;
}

.alert-success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.alert-error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.alert-warning {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffeeba;
}

.alert-info {
    background: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

/* Progress Bar */
.progress {
    height: 25px;
    background: #f0f0f0;
    border-radius: 15px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 12px;
    font-weight: 600;
    transition: width 0.3s ease;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    overflow-y: scroll;
    -webkit-overflow-scrolling: touch;
}

.modal-content {
    background: white;
    margin: 30px auto;
    padding: 30px;
    border-radius: 10px;
    width: 90%;
    max-width: 600px;
    position: relative;
    min-height: 200px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.close {
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    color: #999;
}

.close:hover {
    color: #333;
}

/* Loading Spinner */
.spinner {
    border: 3px solid #f3f3f3;
    border-top: 3px solid #667eea;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 20px auto;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }
    
    .sidebar.active {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0;
        padding: 15px;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    /* Mobile table styles */
    table {
        font-size: 12px;
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    table th, table td {
        padding: 8px 10px;
        white-space: nowrap;
    }
    
    .card {
        padding: 15px;
        margin-bottom: 15px;
    }
    
    .card-header h2 {
        font-size: 16px;
    }
    
    .stat-card {
        padding: 15px;
        flex-direction: column;
        text-align: center;
    }
    
    .stat-icon {
        margin-bottom: 10px;
    }
    
    .stat-info p {
        font-size: 24px;
    }
    
    .header {
        flex-direction: column;
        gap: 15px;
    }
    
    .header h1 {
        font-size: 20px;
    }
    
    .modal-content {
        width: 95%;
        padding: 20px;
        margin: 15px auto;
    }
}

/* Login Page Styles */
.login-page {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}

.login-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    max-width: 1000px;
    width: 100%;
    background: white;
    border-radius: 15px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    overflow: hidden;
}

.login-box {
    padding: 50px 40px;
}

.login-header {
    text-align: center;
    margin-bottom: 30px;
}

.login-header h1 {
    font-size: 28px;
    color: #667eea;
    margin-bottom: 10px;
}

.login-header p {
    color: #666;
    font-size: 14px;
}

.login-form {
    margin-bottom: 20px;
}

.login-footer {
    text-align: center;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #eee;
}

.login-footer p {
    margin: 10px 0;
    font-size: 14px;
    color: #666;
}

.login-footer a {
    color: #667eea;
    text-decoration: none;
    font-weight: 600;
}

.login-footer a:hover {
    text-decoration: underline;
}

.login-info {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 50px 40px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.login-info h2 {
    font-size: 32px;
    margin-bottom: 30px;
    line-height: 1.3;
}

.login-info ul {
    list-style: none;
    margin-bottom: 30px;
}

.login-info ul li {
    padding: 15px 0;
    font-size: 16px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.login-info ul li:last-child {
    border-bottom: none;
}

.version {
    font-size: 12px;
    opacity: 0.7;
    margin-top: auto;
}

/* Responsive Login */
@media (max-width: 768px) {
    .login-container {
        grid-template-columns: 1fr;
    }
    
    .login-info {
        display: none;
    }
}

/* Extra small screens (phones) */
@media (max-width: 480px) {
    body {
        font-size: 14px;
    }
    
    .main-content {
        padding: 10px;
    }
    
    .header {
        padding: 15px;
        font-size: 16px;
    }
    
    .card {
        padding: 10px;
    }
    
    table {
        font-size: 11px;
    }
    
    table th, table td {
        padding: 6px 5px;
    }
    
    .stat-card {
        padding: 10px;
        margin-bottom: 10px;
    }
    
    .stat-icon {
        width: 40px;
        height: 40px;
        font-size: 20px;
    }
    
    .stat-info h3 {
        font-size: 12px;
    }
    
    .stat-info p {
        font-size: 18px;
    }
    
    .btn {
        padding: 8px 12px;
        font-size: 12px;
    }
    
    input[type="text"],
    input[type="password"],
    input[type="email"],
    select,
    textarea {
        padding: 8px 10px;
    }
    
    .modal-content {
        width: 98%;
        padding: 15px;
    }
}

/* Utility Classes */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: #999; }
.mt-20 { margin-top: 20px; }
.mb-20 { margin-bottom: 20px; }
.p-20 { padding: 20px; }

/* Validation Error Styles */
input.validation-error,
select.validation-error,
textarea.validation-error {
    border: 3px solid #f44336 !important;
    background-color: #ffebee !important;
    animation: shake 0.5s;
    box-shadow: 0 0 10px rgba(244, 67, 54, 0.5) !important;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-8px); }
    20%, 40%, 60%, 80% { transform: translateX(8px); }
}

.validation-message {
    color: #f44336;
    font-size: 12px;
    margin-top: 5px;
    display: block;
    font-weight: 500;
}

select:invalid,
select[required]:not([value]),
select[required][value=""] {
    color: #999;
}

select:valid {
    color: #333;
}

/* Highlight form group with error */
.form-group.has-error {
    background: #fff3f3;
    padding: 10px;
    border-radius: 5px;
    border-left: 4px solid #f44336;
}
.d-flex { display: flex; }
.justify-between { justify-content: space-between; }
.align-center { align-items: center; }
.gap-10 { gap: 10px; }

/* ============================================
   MOBILE RESPONSIVE STYLES
   ============================================ */

/* Viewport meta tag support */
@viewport {
    width: device-width;
    zoom: 1;
}

/* Base mobile adjustments */
@media screen and (max-width: 768px) {
    body {
        font-size: 14px;
        -webkit-text-size-adjust: 100%;
    }
    
    .container {
        padding: 10px;
    }
    
    /* Dashboard layout */
    .dashboard {
        display: block;
    }
    
    .main-content {
        margin-left: 0;
        padding: 60px 12px 20px 12px;
        width: 100%;
    }
    
    /* Header adjustments */
    .header {
        padding: 15px;
        flex-direction: column;
        gap: 15px;
        text-align: center;
        margin-bottom: 15px;
    }
    
    .header h1 {
        font-size: 1.4rem;
        line-height: 1.3;
    }
    
    .header .text-muted {
        font-size: 12px;
    }
    
    .header-actions {
        width: 100%;
        justify-content: center;
        flex-wrap: wrap;
    }
    
    /* Card adjustments */
    .card {
        padding: 15px;
        margin-bottom: 15px;
        border-radius: 8px;
    }
    
    .card-header {
        flex-direction: column;
        gap: 10px;
        text-align: center;
    }
    
    .card-header h2 {
        font-size: 1.1rem;
    }
    
    /* Stats grid */
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
        margin-bottom: 15px;
    }
    
    .stat-card {
        padding: 12px;
        flex-direction: column;
        text-align: center;
        gap: 8px;
    }
    
    .stat-info h3 {
        font-size: 11px;
    }
    
    .stat-info p {
        font-size: 1.4rem;
    }
    
    .stat-icon {
        width: 40px;
        height: 40px;
        font-size: 20px;
    }
    
    /* Form adjustments */
    .form-row {
        flex-direction: column;
        gap: 0;
    }
    
    .form-group {
        width: 100%;
        margin-bottom: 12px;
    }
    
    .form-group label {
        font-size: 13px;
        margin-bottom: 6px;
    }
    
    .form-group input,
    .form-group select,
    .form-group textarea {
        font-size: 16px; /* Prevents zoom on iOS */
        padding: 12px;
        border-radius: 6px;
    }
    
    /* Button adjustments */
    .btn {
        padding: 12px 16px;
        font-size: 14px;
        width: 100%;
        text-align: center;
    }
    
    .btn-group {
        flex-direction: column;
        gap: 10px;
    }
    
    .btn-group .btn {
        width: 100%;
    }
    
    /* Table adjustments */
    .table-container,
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin: 0 -15px;
        padding: 0 15px;
    }
    
    table {
        font-size: 12px;
        min-width: 500px;
    }
    
    table th,
    table td {
        padding: 10px 8px;
        white-space: nowrap;
    }
    
    /* Modal adjustments */
    .modal-content {
        width: 95%;
        margin: 10% auto;
        padding: 15px;
        max-height: 85vh;
        overflow-y: auto;
    }
    
    .modal-header {
        padding-bottom: 10px;
    }
    
    .modal-header h2 {
        font-size: 1.1rem;
    }
    
    /* Alert adjustments */
    .alert {
        padding: 12px;
        font-size: 13px;
        margin: 10px 0;
        border-radius: 6px;
    }
    
    /* Badge adjustments */
    .badge {
        font-size: 10px;
        padding: 4px 8px;
    }
    
    /* Filter bar adjustments */
    .filter-bar {
        flex-direction: column;
        gap: 10px;
    }
    
    .filter-bar input,
    .filter-bar select {
        width: 100%;
    }
    
    /* Login page mobile */
    .login-box {
        padding: 20px;
        margin: 20px;
        border-radius: 12px;
    }
    
    .login-box h2 {
        font-size: 1.3rem;
    }
}

/* Extra small devices (phones in portrait) */
@media screen and (max-width: 480px) {
    .main-content {
        padding: 55px 8px 15px 8px;
    }
    
    .header {
        padding: 12px;
    }
    
    .header h1 {
        font-size: 1.2rem;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .stat-card {
        flex-direction: row;
        justify-content: space-between;
        text-align: left;
    }
    
    .card {
        padding: 12px;
    }
    
    .card-header h2 {
        font-size: 1rem;
    }
    
    table {
        font-size: 11px;
    }
    
    .btn {
        padding: 10px 12px;
        font-size: 13px;
    }
}

/* Landscape orientation adjustments */
@media screen and (max-width: 768px) and (orientation: landscape) {
    .main-content {
        padding-top: 50px;
    }
    
    .modal-content {
        margin: 5% auto;
        max-height: 90vh;
    }
}

/* Touch-friendly adjustments */
@media (hover: none) and (pointer: coarse) {
    .menu-item,
    .btn,
    .menu-section-header {
        min-height: 44px; /* Apple's recommended touch target */
    }
    
    .form-group input,
    .form-group select {
        min-height: 44px;
    }
    
    /* Remove hover effects on touch */
    .menu-item:hover,
    .btn:hover {
        transform: none;
    }
}

/* Print styles for mobile */
@media print {
    .sidebar,
    .sidebar-toggle,
    .sidebar-overlay,
    .header-actions {
        display: none !important;
    }
    
    .main-content {
        margin-left: 0 !important;
        padding: 0 !important;
    }
}

