/* Reset & Body */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #1a0f2e;
    color: #eee;
    line-height: 1.6;
}

/* Layout */
.layout {
    display: flex;
    min-height: calc(100vh - 70px);
}

/* Header */
.app-header {
    background: linear-gradient(135deg, #2c1b47, #4b2e83);
    color: white;
    padding: 5px 5px;
    text-align: center;
    font-size: 1rem;
    font-weight: bold;
    letter-spacing: 2px;
    border-bottom: 3px solid #7209b7;
    box-shadow: 0 2px 10px rgba(0,0,0,0.3);
    position: sticky;
    top: 0;
    z-index: 1000;
}

/* Sidebar */
.sidebar {
    width: 250px;
    background: linear-gradient(180deg, #2c1b47, #1e1433);
    padding: 30px 20px;
    box-shadow: 2px 0 10px rgba(0,0,0,0.3);
    position: fixed;
    height: calc(100vh - 70px);
    top: 70px;
    left: 0;
    overflow-y: auto;
}

.sidebar h2 {
    color: #bb86fc;
    text-align: center;
    margin-bottom: 40px;
    font-size: 1.3rem;
    border-bottom: 2px solid #4b2e83;
    padding-bottom: 15px;
}

.sidebar a {
    display: block;
    color: #eee;
    padding: 15px 20px;
    margin-bottom: 10px;
    text-decoration: none;
    border-radius: 10px;
    transition: all 0.3s ease;
    font-weight: 500;
    position: relative;
    overflow: hidden;
}

.sidebar a::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(187, 134, 252, 0.2), transparent);
    transition: left 0.5s;
}

.sidebar a:hover::before {
    left: 100%;
}

.sidebar a.active {
    background: linear-gradient(135deg, #4b2e83, #6a4c93);
    color: #fff;
    box-shadow: 0 4px 15px rgba(75, 46, 131, 0.4);
    transform: translateX(5px);
}

.sidebar a:hover {
    background: #3c2460;
    transform: translateX(5px);
    box-shadow: 0 4px 15px rgba(60, 36, 96, 0.3);
}

/* Main Content */
.main {
    margin-left: 250px;
    padding: 30px;
    flex-grow: 1;
    background: #1a0f2e;
    min-height: calc(100vh - 70px);
}

/* Section Headers */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding-bottom: 15px;
    border-bottom: 2px solid #4b2e83;
}

.section-header h2 {
    color: #bb86fc;
    font-size: 2rem;
    font-weight: bold;
}

.add-btn {
    background: linear-gradient(135deg, #2ecc71, #27ae60);
    color: white;
    padding: 12px 25px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(46, 204, 113, 0.3);
}

.add-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(46, 204, 113, 0.4);
}

/* Filter Bar */
.filter-bar {
    background: #2c1b47;
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 25px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    border: 1px solid #4b2e83;
}

.search-group, .filter-group {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    align-items: center;
}

.search-group {
    margin-bottom: 15px;
}

.search-input, .filter-select, .date-input {
    background: #1a0f2e;
    border: 2px solid #4b2e83;
    color: #eee;
    padding: 12px 15px;
    border-radius: 8px;
    font-size: 14px;
    transition: all 0.3s ease;
    min-width: 200px;
}

.search-input:focus, .filter-select:focus, .date-input:focus {
    outline: none;
    border-color: #bb86fc;
    box-shadow: 0 0 0 3px rgba(187, 134, 252, 0.1);
}

.clear-btn {
    background: #e74c3c;
    color: white;
    padding: 12px 20px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.3s ease;
}

.clear-btn:hover {
    background: #c0392b;
    transform: translateY(-1px);
}

/* Table Container */
.table-container {
    background: #2c1b47;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 8px 25px rgba(0,0,0,0.3);
    border: 1px solid #4b2e83;
}

/* Tables */
table {
    width: 100%;
    border-collapse: collapse;
    background: transparent;
}

th, td {
    padding: 15px 12px;
    text-align: left;
    border-bottom: 1px solid #3c2460;
}

th {
    background: linear-gradient(135deg, #4b2e83, #3c2460);
    color: #bb86fc;
    font-weight: bold;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 1px;
    position: sticky;
    top: 0;
    z-index: 10;
}

tbody tr {
    transition: all 0.3s ease;
}

tbody tr:hover {
    background: rgba(75, 46, 131, 0.3);
    transform: scale(1.001);
}

tbody tr:nth-child(even) {
    background: rgba(26, 15, 46, 0.3);
}

/* Action Buttons */
.action-buttons {
    display: flex;
    gap: 5px;
    flex-wrap: wrap;
    justify-content: center;
}

button {
    padding: 8px 12px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: bold;
    font-size: 12px;
    transition: all 0.3s ease;
    min-width: 60px;
}

.in-btn {
    background: linear-gradient(135deg, #3498db, #2980b9);
    color: white;
}

.in-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(52, 152, 219, 0.4);
}

.out-btn {
    background: linear-gradient(135deg, #f39c12, #e67e22);
    color: white;
}

.out-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(243, 156, 18, 0.4);
}

.edit-btn {
    background: linear-gradient(135deg, #9b59b6, #8e44ad);
    color: white;
}

.edit-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(155, 89, 182, 0.4);
}

.delete-btn {
    background: linear-gradient(135deg, #e74c3c, #c0392b);
    color: white;
}

.delete-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(231, 76, 60, 0.4);
}

button:disabled {
    background: #6c757d !important;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
    opacity: 0.6;
}

/* Loading, Error, Empty States */
.loading {
    text-align: center;
    padding: 3rem;
    color: #bb86fc;
    font-style: italic;
    font-size: 1.2rem;
    background: #2c1b47;
    border-radius: 12px;
    margin: 20px 0;
}

.error {
    background: linear-gradient(135deg, #8b1538, #721229);
    color: #f8d7da;
    padding: 20px;
    border-radius: 12px;
    margin: 20px 0;
    border: 1px solid #d32f2f;
    box-shadow: 0 4px 15px rgba(139, 21, 56, 0.3);
}

.empty-state {
    text-align: center;
    padding: 4rem;
    color: #bb86fc;
    font-style: italic;
    font-size: 1.2rem;
    background: #2c1b47;
    border-radius: 12px;
    margin: 20px 0;
    border: 2px dashed #4b2e83;
}

/* Sections */
#itemsSection, #itemsendSection {
    background: transparent;
}

/* Modal Styles */
.modal {
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
}

.modal-content {
    background: linear-gradient(135deg, #2c1b47, #1e1433);
    margin: 5% auto;
    padding: 0;
    border-radius: 15px;
    width: 80%;
    max-width: 600px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    border: 1px solid #4b2e83;
    animation: modalSlideIn 0.3s ease;
}

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

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 25px 30px;
    border-bottom: 2px solid #4b2e83;
    background: linear-gradient(135deg, #4b2e83, #3c2460);
    border-radius: 15px 15px 0 0;
}

.modal-header h3 {
    color: #bb86fc;
    font-size: 1.5rem;
    margin: 0;
}

.close {
    color: #bb86fc;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    padding: 5px 10px;
    border-radius: 50%;
}

.close:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.1);
    transform: scale(1.1);
}

/* Form Styles */
#itemForm, #transactionForm {
    padding: 30px;
}

.form-row {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
}

.form-group {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.form-group label {
    color: #bb86fc;
    margin-bottom: 8px;
    font-weight: bold;
    font-size: 14px;
}

.form-group input, .form-group select {
    background: #1a0f2e;
    border: 2px solid #4b2e83;
    color: #eee;
    padding: 12px 15px;
    border-radius: 8px;
    font-size: 14px;
    transition: all 0.3s ease;
}

.form-group input:focus, .form-group select:focus {
    outline: none;
    border-color: #bb86fc;
    box-shadow: 0 0 0 3px rgba(187, 134, 252, 0.1);
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 15px;
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid #4b2e83;
}

.save-btn {
    background: linear-gradient(135deg, #2ecc71, #27ae60);
    color: white;
    padding: 12px 25px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(46, 204, 113, 0.3);
}

.save-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(46, 204, 113, 0.4);
}

.cancel-btn {
    background: #6c757d;
    color: white;
    padding: 12px 25px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.3s ease;
}

.cancel-btn:hover {
    background: #5a6268;
    transform: translateY(-2px);
}

/* Responsive Design */
@media (max-width: 1200px) {
    .main {
        margin-left: 250px;
        padding: 20px;
    }
}

@media (max-width: 968px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .main {
        margin-left: 0;
        padding: 15px;
    }
    
    .filter-bar {
        padding: 15px;
    }
    
    .search-group, .filter-group {
        flex-direction: column;
        align-items: stretch;
    }
    
    .search-input, .filter-select, .date-input {
        min-width: auto;
        width: 100%;
    }
    
    .form-row {
        flex-direction: column;
        gap: 15px;
    }
    
    .modal-content {
        width: 95%;
        margin: 10% auto;
    }
    
    .section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }
    
    .add-btn {
        width: 100%;
        text-align: center;
    }
}

@media (max-width: 768px) {
    .app-header {
        font-size: 1.4rem;
        padding: 12px 15px;
    }
    
    .main {
        padding: 10px;
    }
    
    table {
        font-size: 12px;
    }
    
    th, td {
        padding: 10px 8px;
    }
    
    .action-buttons {
        flex-direction: column;
        gap: 3px;
    }
    
    button {
        padding: 6px 10px;
        font-size: 11px;
        min-width: 50px;
    }
    
    .modal-content {
        width: 98%;
        margin: 5% auto;
    }
    
    .modal-header {
        padding: 20px;
    }
    
    #itemForm, #transactionForm {
        padding: 20px;
    }
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #1a0f2e;
}

::-webkit-scrollbar-thumb {
    background: #4b2e83;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #6a4c93;
}

/* Animation Classes */
.fade-in {
    animation: fadeIn 0.5s ease-in;
}

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