/* ==================== 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;
}

/* ==================== SCREEN MANAGEMENT ==================== */

.screen {
    display: none;
}

.screen.active {
    display: block;
}

/* ==================== LOGIN SCREEN ==================== */

.login-container {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}

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

.login-header h1 {
    font-size: 3em;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.login-header p {
    font-size: 1.2em;
    opacity: 0.9;
}

.login-box {
    background: white;
    padding: 40px;
    border-radius: 15px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    width: 100%;
    max-width: 400px;
}

.login-box h2 {
    text-align: center;
    margin-bottom: 30px;
    color: #667eea;
}

.login-info {
    margin-top: 20px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
    font-size: 0.9em;
    color: #666;
}

.login-info p {
    margin: 5px 0;
}

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

.header {
    background: white;
    padding: 20px 40px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-left h1 {
    color: #667eea;
    margin-bottom: 5px;
    font-size: 1.8em;
}

.header-left p {
    color: #666;
    font-size: 0.9em;
}

/* ==================== CONTAINER ==================== */

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

/* ==================== CARDS ==================== */

.card {
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    padding: 30px;
    margin-bottom: 30px;
}

.card h2 {
    color: #333;
    margin-bottom: 20px;
    font-size: 1.5em;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.card-header h2 {
    margin: 0;
}

/* ==================== FORMS ==================== */

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

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #555;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 1em;
    transition: border-color 0.3s;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: #667eea;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

/* ==================== BUTTONS ==================== */

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.btn-primary {
    background: #667eea;
    color: white;
}

.btn-primary:hover {
    background: #5568d3;
}

.btn-success {
    background: #48bb78;
    color: white;
}

.btn-success:hover {
    background: #38a169;
}

.btn-danger {
    background: #f56565;
    color: white;
}

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

.btn-warning {
    background: #ed8936;
    color: white;
}

.btn-warning:hover {
    background: #dd6b20;
}

.btn-secondary {
    background: #718096;
    color: white;
}

.btn-secondary:hover {
    background: #4a5568;
}

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

.btn-small {
    padding: 8px 16px;
    font-size: 0.9em;
}

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

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

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
}

thead {
    background: #667eea;
    color: white;
}

thead th {
    padding: 15px;
    text-align: left;
    font-weight: 600;
}

tbody td {
    padding: 15px;
    border-bottom: 1px solid #e0e0e0;
}

tbody tr:hover {
    background: #f7fafc;
}

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

.action-buttons {
    display: flex;
    gap: 10px;
}

/* ==================== PRODUCTS GRID (Billing) ==================== */

.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.product-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 25px;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s;
}

.product-card:hover {
    transform: translateY(-5px);
}

.product-card h3 {
    margin-bottom: 15px;
    font-size: 1.3em;
}

.product-info {
    margin-bottom: 15px;
}

.product-info p {
    margin: 8px 0;
    font-size: 1.1em;
}

.stock-badge {
    display: inline-block;
    padding: 5px 15px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 20px;
    font-size: 0.9em;
    font-weight: 600;
}

.out-of-stock {
    opacity: 0.6;
}

.out-of-stock-badge {
    background: #f56565;
    color: white;
    padding: 5px 15px;
    border-radius: 20px;
    font-weight: 600;
}

/* ==================== HISTORY ==================== */

.history-container {
    max-height: 400px;
    overflow-y: auto;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 8px;
}

.history-item {
    background: white;
    padding: 15px;
    margin-bottom: 10px;
    border-radius: 8px;
    border-left: 4px solid #667eea;
}

.history-item.billing-item {
    border-left-color: #48bb78;
}

.history-item strong {
    color: #667eea;
}

.history-item .timestamp {
    color: #999;
    font-size: 0.9em;
    margin-top: 5px;
}

.no-history {
    text-align: center;
    padding: 40px;
    color: #999;
}

/* ==================== MODAL ==================== */

.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    animation: fadeIn 0.3s;
}

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: white;
    padding: 0;
    border-radius: 15px;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    animation: slideUp 0.3s;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 25px 30px;
    border-bottom: 2px solid #e0e0e0;
}

.modal-header h2 {
    margin: 0;
    color: #667eea;
}

.close {
    font-size: 2em;
    font-weight: bold;
    color: #999;
    cursor: pointer;
    transition: color 0.3s;
}

.close:hover {
    color: #333;
}

.modal-content form {
    padding: 30px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 15px;
    margin-top: 25px;
}

.purchase-info {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.purchase-info h3 {
    color: #667eea;
    margin-bottom: 10px;
}

.purchase-info p {
    margin: 5px 0;
    font-size: 1.1em;
}

.purchase-total {
    background: #667eea;
    color: white;
    padding: 20px;
    border-radius: 8px;
    text-align: center;
    margin-top: 20px;
}

.purchase-total h3 {
    font-size: 1.8em;
}

/* ==================== TOAST NOTIFICATION ==================== */

.toast {
    position: fixed;
    bottom: 30px;
    right: 30px;
    padding: 20px 30px;
    background: #333;
    color: white;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    z-index: 2000;
    transform: translateX(400px);
    transition: transform 0.3s;
}

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

.toast.success {
    background: #48bb78;
}

.toast.error {
    background: #f56565;
}

/* ==================== ERROR MESSAGE ==================== */

.error-message {
    color: #f56565;
    text-align: center;
    margin-top: 15px;
    padding: 10px;
    background: #fff5f5;
    border-radius: 8px;
    display: none;
}

.error-message.show {
    display: block;
}

/* ==================== ANIMATIONS ==================== */

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

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

/* ==================== RESPONSIVE DESIGN ==================== */

@media (max-width: 768px) {
    .header {
        padding: 15px 20px;
    }

    .header-left h1 {
        font-size: 1.3em;
    }

    .login-header h1 {
        font-size: 2em;
    }

    .card {
        padding: 20px;
    }

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

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

    .action-buttons {
        flex-direction: column;
    }

    .card-header {
        flex-direction: column;
        gap: 15px;
        align-items: flex-start;
    }

    .toast {
        right: 10px;
        left: 10px;
        bottom: 10px;
    }
}

/* ==================== SCROLLBAR STYLING ==================== */

::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

::-webkit-scrollbar-thumb {
    background: #667eea;
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: #5568d3;
}
