/* Reset and Base 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 {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
header {
    background: white;
    padding: 20px;
    border-radius: 15px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    margin-bottom: 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
}

header h1 {
    color: #667eea;
    font-size: 2.5em;
    font-weight: 600;
}

header h1 i {
    margin-right: 10px;
    color: #e74c3c;
}

.header-actions {
    display: flex;
    gap: 10px;
}

/* Buttons */
.btn {
    padding: 12px 20px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
    font-size: 14px;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

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

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

.btn-success {
    background: #28a745;
    color: white;
}

.btn-success:hover {
    background: #218838;
    transform: translateY(-2px);
}

.btn-warning {
    background: #ffc107;
    color: #212529;
}

.btn-warning:hover {
    background: #e0a800;
    transform: translateY(-2px);
}

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

.btn-danger:hover {
    background: #c82333;
    transform: translateY(-2px);
}

.btn-info {
    background: #17a2b8;
    color: white;
}

.btn-info:hover {
    background: #138496;
    transform: translateY(-2px);
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

/* Sections */
section {
    background: white;
    padding: 25px;
    border-radius: 15px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    margin-bottom: 30px;
}

section h2 {
    color: #667eea;
    margin-bottom: 20px;
    font-size: 1.8em;
    font-weight: 600;
}

section h2 i {
    margin-right: 10px;
}

/* Alerts Section */
.alerts-section {
    background: linear-gradient(135deg, #ff6b6b, #ee5a52);
    color: white;
}

.alerts-section h2 {
    color: white;
}

.alerts-list {
    display: grid;
    gap: 15px;
}

.alert-item {
    background: rgba(255, 255, 255, 0.1);
    padding: 15px;
    border-radius: 10px;
    border-left: 4px solid #fff;
    backdrop-filter: blur(10px);
}

.alert-item h4 {
    margin-bottom: 5px;
    font-size: 1.1em;
}

.alert-item p {
    opacity: 0.9;
}

.no-alerts {
    text-align: center;
    padding: 20px;
    opacity: 0.8;
    font-style: italic;
}

/* Forms */
.add-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

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

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

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

.form-group input,
.form-group select {
    padding: 12px;
    border: 2px solid #e1e5e9;
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.3s ease;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* Inventory List */
.inventory-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 20px;
}

.inventory-item {
    background: linear-gradient(135deg, #f8f9fa, #e9ecef);
    padding: 20px;
    border-radius: 12px;
    border: 2px solid #e1e5e9;
    transition: all 0.3s ease;
}

.inventory-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

.inventory-item.low-stock {
    border-color: #dc3545;
    background: linear-gradient(135deg, #fff5f5, #ffe6e6);
}

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

.inventory-header h3 {
    color: #333;
    font-size: 1.3em;
    margin: 0;
}

.stock-status {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stock-status.good {
    background: #d4edda;
    color: #155724;
}

.stock-status.low {
    background: #f8d7da;
    color: #721c24;
}

.stock-status.out {
    background: #f5c6cb;
    color: #721c24;
}

.inventory-details {
    margin-bottom: 15px;
}

.inventory-details p {
    margin-bottom: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.inventory-details strong {
    color: #667eea;
}

.inventory-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.inventory-actions .btn {
    flex: 1;
    min-width: 80px;
    justify-content: center;
    font-size: 12px;
    padding: 8px 12px;
}

/* Usage Controls */
.usage-controls {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
    align-items: center;
    flex-wrap: wrap;
}

.usage-controls select,
.usage-controls input {
    padding: 10px;
    border: 2px solid #e1e5e9;
    border-radius: 8px;
    font-size: 14px;
}

/* Usage History */
.usage-history {
    max-height: 500px;
    overflow-y: auto;
    border: 1px solid #e1e5e9;
    border-radius: 8px;
}

.usage-item {
    padding: 15px;
    border-bottom: 1px solid #e1e5e9;
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 15px;
    align-items: center;
}

.usage-item:last-child {
    border-bottom: none;
}

.usage-item:nth-child(even) {
    background: #f8f9fa;
}

.usage-info h4 {
    margin-bottom: 5px;
    color: #333;
}

.usage-info p {
    color: #666;
    font-size: 14px;
    margin-bottom: 3px;
}

.usage-type {
    padding: 4px 8px;
    border-radius: 15px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
}

.usage-type.add {
    background: #d4edda;
    color: #155724;
}

.usage-type.use {
    background: #fff3cd;
    color: #856404;
}

.usage-type.remove {
    background: #f8d7da;
    color: #721c24;
}

.usage-timestamp {
    font-size: 12px;
    color: #666;
    text-align: right;
}

/* 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);
    backdrop-filter: blur(5px);
}

.modal-content {
    background-color: white;
    margin: 5% auto;
    padding: 30px;
    border-radius: 15px;
    width: 90%;
    max-width: 500px;
    position: relative;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
}

.close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    position: absolute;
    right: 20px;
    top: 15px;
    cursor: pointer;
}

.close:hover,
.close:focus {
    color: #333;
}

.modal-content h3 {
    margin-bottom: 20px;
    color: #667eea;
    font-size: 1.5em;
}

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

/* Empty States */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: #666;
}

.empty-state i {
    font-size: 3em;
    margin-bottom: 15px;
    opacity: 0.5;
}

.empty-state h3 {
    margin-bottom: 10px;
    color: #333;
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }

    header {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }

    header h1 {
        font-size: 2em;
    }

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

    .inventory-list {
        grid-template-columns: 1fr;
    }

    .inventory-actions {
        flex-direction: column;
    }

    .inventory-actions .btn {
        flex: none;
    }

    .usage-item {
        grid-template-columns: 1fr;
        gap: 10px;
        text-align: center;
    }

    .usage-controls {
        flex-direction: column;
        align-items: stretch;
    }

    .modal-content {
        margin: 10% auto;
        width: 95%;
        padding: 20px;
    }

    .modal-actions {
        flex-direction: column;
    }
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.inventory-item,
.usage-item,
.alert-item {
    animation: fadeIn 0.3s ease-out;
}

/* Print Styles */
@media print {
    body {
        background: white;
    }

    .container {
        max-width: none;
        margin: 0;
        padding: 20px;
    }

    .btn,
    .header-actions,
    .inventory-actions,
    .usage-controls {
        display: none !important;
    }

    section {
        box-shadow: none;
        border: 1px solid #ddd;
        page-break-inside: avoid;
    }
}

/* Tab Navigation */
.main-content {
    background: white;
    border-radius: 15px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    margin-bottom: 30px;
    overflow: hidden;
}

.tab-navigation {
    display: flex;
    background: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
}

.tab-btn {
    flex: 1;
    padding: 15px 20px;
    background: none;
    border: none;
    color: #6c757d;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    border-bottom: 3px solid transparent;
}

.tab-btn:hover {
    background: #e9ecef;
    color: #495057;
}

.tab-btn.active {
    background: white;
    color: #667eea;
    border-bottom-color: #667eea;
}

.tab-btn i {
    margin-right: 8px;
}

.tab-content {
    display: none;
    padding: 30px;
}

.tab-content.active {
    display: block;
}

.tab-header {
    margin-bottom: 25px;
}

.tab-header h2 {
    color: #667eea;
    margin-bottom: 10px;
}

.tab-description {
    color: #6c757d;
    font-style: italic;
}

/* In-Use Items Styles */
.in-use-list {
    display: grid;
    gap: 20px;
}

.in-use-item {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 10px;
    padding: 20px;
    transition: all 0.3s ease;
}

.in-use-item:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

.in-use-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.in-use-header h3 {
    color: #667eea;
    margin: 0;
}

.status-badge {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.85em;
    font-weight: 500;
    text-transform: uppercase;
}

.status-badge.active {
    background: #d4edda;
    color: #155724;
}

.status-badge.ending-soon {
    background: #fff3cd;
    color: #856404;
}

.status-badge.overdue {
    background: #f8d7da;
    color: #721c24;
}

.in-use-details {
    margin-bottom: 20px;
}

.in-use-details p {
    margin-bottom: 8px;
    color: #495057;
}

.in-use-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

/* Form Enhancements */
.form-hint {
    display: block;
    color: #6c757d;
    font-size: 0.85em;
    margin-top: 5px;
    font-style: italic;
}

#customDurationGroup {
    margin-top: 15px;
}

.duration-inputs {
    display: flex;
    align-items: center;
    gap: 10px;
}

.duration-inputs input {
    width: 80px;
}

.duration-inputs span {
    color: #6c757d;
    font-size: 0.9em;
}

/* Units Progress Bar */
.units-progress {
    width: 100%;
    height: 8px;
    background: #e9ecef;
    border-radius: 4px;
    overflow: hidden;
    margin-top: 5px;
}

.units-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #28a745 0%, #ffc107 70%, #dc3545 90%);
    transition: width 0.3s ease;
}

/* Enhanced Modal Styles */
.modal {
    z-index: 1001;
}

.modal-content h3 {
    color: #667eea;
    margin-bottom: 20px;
}

/* Autocomplete Styles */
#itemName {
    position: relative;
}

datalist {
    display: none;
}

/* Enhanced Button Styles */
.btn.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.btn.btn-primary:hover {
    background: linear-gradient(135deg, #5a6fd8 0%, #6a4190 100%);
}

/* Responsive Design for Tabs */
@media (max-width: 768px) {
    .tab-btn {
        padding: 12px 10px;
        font-size: 0.9em;
    }

    .tab-btn i {
        display: block;
        margin-right: 0;
        margin-bottom: 5px;
    }

    .in-use-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .in-use-actions {
        justify-content: center;
    }

    .tab-navigation {
        flex-wrap: wrap;
    }

    .tab-content {
        padding: 20px;
    }
}