* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f5f5f5;
    color: #333;
    line-height: 1.6;
    padding-bottom: 70px; /* Space for bottom nav */
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    padding-bottom: 20px;
}

/* Page System */
.page {
    display: none;
}

.page.active {
    display: block;
}

/* Header */
header {
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    margin-bottom: 20px;
    position: relative;
}

header h1 {
    text-align: center;
    color: #2c3e50;
    margin-bottom: 20px;
}

/* Global Stats */
.global-stats {
    display: flex;
    justify-content: center;
}

.stat-card {
    text-align: center;
    padding: 15px;
    border-radius: 8px;
    background: #f8f9fa;
    width: 100%;
}

.stat-card h3 {
    font-size: 1rem;
    margin-bottom: 10px;
    color: #6c757d;
}

.profit {
    font-size: 2rem;
    font-weight: bold;
}

.profit.positive {
    color: #28a745;
}

.profit.negative {
    color: #dc3545;
}

.today-profit {
    font-size: 1rem;
    color: #6c757d;
    margin-top: 5px;
}

/* Recent Records */
.recent-records-section h2 {
    color: #2c3e50;
    margin-bottom: 15px;
}

.record-item {
    background: white;
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.record-item .record-info {
    flex: 1;
}

.record-item .record-details {
    display: flex;
    gap: 15px;
}

.record-item .record-profit {
    font-weight: bold;
}

.record-item .record-profit.positive {
    color: #28a745;
}

.record-item .record-profit.negative {
    color: #dc3545;
}

/* Quick Actions */
.quick-actions {
    display: flex;
    gap: 15px;
    margin-top: 20px;
}

.quick-actions button {
    flex: 1;
}

/* Search Container */
.search-container {
    margin-bottom: 20px;
}

.search-container input {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 1rem;
}

/* Items List */
.items-list-section {
    margin-top: 20px;
}

.item-card {
    background: white;
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    margin-bottom: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
}

.item-card .item-info h3 {
    margin-bottom: 5px;
}

.item-card .item-details {
    display: flex;
    gap: 15px;
}

.item-card .item-profit {
    font-weight: bold;
}

.item-card .item-profit.positive {
    color: #28a745;
}

.item-card .item-profit.negative {
    color: #dc3545;
}

.item-card .arrow {
    font-size: 1.5rem;
    color: #ccc;
}

/* Item Detail */
#item-detail-page header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.back-btn, .simulate-btn {
    background: none;
    border: none;
    font-size: 1rem;
    cursor: pointer;
    padding: 10px;
}

.simulate-btn {
    background: #007bff;
    color: white;
    border-radius: 4px;
}

/* Item Summary */
.item-summary {
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    margin-bottom: 20px;
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 15px;
    margin-top: 15px;
}

.summary-item {
    text-align: center;
}

.summary-item .label {
    font-size: 0.9rem;
    color: #6c757d;
    margin-bottom: 5px;
}

.summary-item .value {
    font-size: 1.2rem;
    font-weight: bold;
}

.summary-item .value.profit.positive {
    color: #28a745;
}

.summary-item .value.profit.negative {
    color: #dc3545;
}

/* Item History */
.item-history h2 {
    color: #2c3e50;
    margin-bottom: 15px;
}

.history-record {
    background: white;
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    margin-bottom: 10px;
}

.history-record .record-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
}

.history-record .operation-type.buy {
    color: #007bff;
    font-weight: bold;
}

.history-record .operation-type.sell {
    color: #dc3545;
    font-weight: bold;
}

.history-record .record-details {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 10px;
}

.history-record .detail-item {
    text-align: center;
}

.history-record .detail-label {
    font-size: 0.8rem;
    color: #6c757d;
}

.history-record .detail-value {
    font-weight: bold;
}

.history-record .profit.positive {
    color: #28a745;
}

.history-record .profit.negative {
    color: #dc3545;
}

.history-record.revoked {
    opacity: 0.6;
    background: #f8f9fa;
}

.history-record.revoked .revoked-label {
    color: #6c757d;
    font-style: italic;
}

/* Item Detail Actions */
.item-detail-actions {
    margin-top: 20px;
    text-align: center;
}

/* Forms */
.form-group {
    margin-bottom: 20px;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
}

label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
}

input, select {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
}

input:focus, select:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 2px rgba(0,123,255,0.25);
}

.stock-info {
    font-size: 0.9rem;
    color: #6c757d;
    margin-top: 5px;
}

.hidden {
    display: none;
}

/* Buttons */
.btn-primary, .btn-secondary, .btn-warning {
    padding: 12px 20px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    transition: background-color 0.2s;
}

.btn-primary {
    background-color: #007bff;
    color: white;
}

.btn-primary:hover {
    background-color: #0069d9;
}

.btn-secondary {
    background-color: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background-color: #5a6268;
}

.btn-warning {
    background-color: #ffc107;
    color: #212529;
}

.btn-warning:hover {
    background-color: #e0a800;
}

/* Simulation Results */
.simulation-results {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 4px;
    margin: 20px 0;
}

.result-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid #eee;
}

.result-row:last-child {
    border-bottom: none;
}

/* Form Actions */
.form-actions {
    display: flex;
    gap: 15px;
    margin-top: 20px;
}

.form-actions button {
    flex: 1;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: white;
    border-radius: 8px;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-content.full-screen {
    width: 100%;
    height: 100%;
    max-width: none;
    max-height: none;
    border-radius: 0;
}

.modal-header {
    padding: 20px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    margin: 0;
}

.modal-body {
    padding: 20px;
}

.close {
    font-size: 28px;
    cursor: pointer;
    color: #aaa;
}

.close:hover {
    color: #333;
}

/* Modal Actions */
.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
}

/* Bottom Navigation */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-around;
    align-items: center;
    background: white;
    border-top: 1px solid #ddd;
    padding: 10px 0;
    z-index: 999;
}

.nav-btn {
    background: none;
    border: none;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 5px 15px;
    border-radius: 8px;
    transition: background-color 0.2s;
}

.nav-btn.active {
    background-color: #e9ecef;
}

.nav-btn.add-btn {
    background-color: #007bff;
    color: white;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    margin-top: -20px;
    font-size: 2rem;
    display: flex;
    justify-content: center;
    align-items: center;
}

.nav-btn.add-btn.loading {
    animation: rotate 1s linear infinite;
}

.nav-btn.add-btn.loading .nav-icon {
    display: inline-block;
    animation: rotate 1s linear infinite;
}

@keyframes rotate {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

.nav-icon {
    font-size: 1.2rem;
}

.nav-label {
    font-size: 0.8rem;
    margin-top: 3px;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: #6c757d;
}

.empty-state p {
    margin-top: 10px;
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .quick-actions {
        flex-direction: column;
    }
    
    .summary-grid {
        grid-template-columns: 1fr 1fr;
    }
    
    .history-record .record-details {
        grid-template-columns: 1fr 1fr;
    }
    
    .modal-content {
        width: 95%;
    }
}

/* Add styles for invalid form fields */
input.invalid {
    border-color: #dc3545;
    box-shadow: 0 0 0 2px rgba(220,53,69,0.25);
}

/* Add styles for warning form fields */
input.warning {
    border-color: #ffc107;
    box-shadow: 0 0 0 2px rgba(255,193,7,0.25);
}

/* Add styles for success message */
.success-message {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background-color: #28a745;
    color: white;
    padding: 15px 20px;
    border-radius: 4px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
    z-index: 2000;
    opacity: 0;
    transition: opacity 0.3s;
}

/* Add animation for modal */
.modal.closing {
    animation: fadeOut 0.3s forwards;
}

@keyframes fadeOut {
    from {
        opacity: 1;
    }
    to {
        opacity: 0;
    }
}

/* Add styles for modal entrance animation */
.modal-content {
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        transform: translateY(100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Add styles for recent records animation */
.record-item {
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Add styles for item card animation */
.item-card {
    transition: all 0.3s ease;
}

.item-card.updated {
    animation: flash 0.5s;
}

@keyframes flash {
    0% { background-color: #fff; }
    50% { background-color: #e9ecef; }
    100% { background-color: #fff; }
}
