/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    color: #333;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
}

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

/* Header */
header {
    text-align: center;
    margin-bottom: 40px;
    color: white;
}

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

header p {
    font-size: 1.2rem;
    opacity: 0.9;
}

/* Main content */
main {
    background: white;
    border-radius: 15px;
    padding: 40px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    margin-bottom: 40px;
}

.hero {
    text-align: center;
    margin-bottom: 50px;
}

.hero h2 {
    font-size: 2.5rem;
    margin-bottom: 15px;
    color: #4a5568;
}

.hero p {
    font-size: 1.1rem;
    color: #718096;
    margin-bottom: 30px;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 12px 30px;
    text-decoration: none;
    border-radius: 25px;
    font-weight: 600;
    transition: all 0.3s ease;
    margin: 0 10px;
    border: none;
    cursor: pointer;
    font-size: 1rem;
}

.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-secondary {
    background: transparent;
    color: #667eea;
    border: 2px solid #667eea;
}

.btn-secondary:hover {
    background: #667eea;
    color: white;
    transform: translateY(-2px);
}

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

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

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

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

/* Features */
.features {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 30px;
    margin-top: 40px;
}

.feature {
    text-align: center;
    padding: 30px 20px;
    border-radius: 10px;
    background: #f7fafc;
    transition: transform 0.3s ease;
}

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

.feature h3 {
    font-size: 1.5rem;
    margin-bottom: 15px;
    color: #4a5568;
}

.feature p {
    color: #718096;
}

/* Forms */
.form-container {
    max-width: 400px;
    margin: 0 auto;
    background: white;
    padding: 40px;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}

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

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    color: #4a5568;
}

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

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

.form-submit {
    width: 100%;
    margin-top: 20px;
}

/* Dashboard */
.dashboard {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 30px;
    margin-bottom: 40px;
}

.card {
    background: white;
    padding: 30px;
    border-radius: 15px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
    text-align: center;
}

.card h3 {
    margin-bottom: 15px;
    color: #4a5568;
}

.water-counter {
    font-size: 3rem;
    font-weight: bold;
    color: #667eea;
    margin: 20px 0;
}

.drink-button {
    font-size: 1.2rem;
    padding: 15px 40px;
    border-radius: 50px;
    background: linear-gradient(135deg, #4299e1 0%, #3182ce 100%);
    color: white;
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
}

.drink-button:hover {
    transform: scale(1.05);
    box-shadow: 0 5px 20px rgba(66, 153, 225, 0.4);
}

/* Navigation */
.nav {
    background: rgba(255,255,255,0.1);
    padding: 15px 0;
    margin-bottom: 30px;
    border-radius: 10px;
}

.nav ul {
    list-style: none;
    display: flex;
    justify-content: center;
    gap: 30px;
}

.nav a {
    color: white;
    text-decoration: none;
    font-weight: 500;
    transition: opacity 0.3s ease;
}

.nav a:hover {
    opacity: 0.8;
}

/* Groups */
.groups-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
    margin-top: 30px;
}

.group-card {
    background: white;
    padding: 25px;
    border-radius: 10px;
    box-shadow: 0 3px 10px rgba(0,0,0,0.1);
    transition: transform 0.3s ease;
}

.group-card:hover {
    transform: translateY(-3px);
}

.group-card h4 {
    margin-bottom: 10px;
    color: #4a5568;
}

.group-card p {
    color: #718096;
    margin-bottom: 15px;
}

.member-count {
    font-size: 0.9rem;
    color: #a0aec0;
    margin-bottom: 15px;
}

/* Stats */
.stats-container {
    margin-top: 30px;
}

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

/* Footer */
footer {
    text-align: center;
    color: white;
    opacity: 0.8;
    margin-top: 40px;
}

/* Responsive */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    header h1 {
        font-size: 2rem;
    }
    
    .hero h2 {
        font-size: 2rem;
    }
    
    main {
        padding: 20px;
    }
    
    .features {
        grid-template-columns: 1fr;
    }
    
    .nav ul {
        flex-direction: column;
        gap: 15px;
    }
}

/* Utility classes */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }
.mb-20 { margin-bottom: 20px; }
.mt-20 { margin-top: 20px; }
.hidden { display: none; }

/* Loading spinner */
.spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px 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); }
}

/* Alerts */
.alert {
    padding: 15px;
    margin-bottom: 20px;
    border-radius: 8px;
    font-weight: 500;
}

.alert-success {
    background: #c6f6d5;
    color: #22543d;
    border: 1px solid #9ae6b4;
}

.alert-error {
    background: #fed7d7;
    color: #742a2a;
    border: 1px solid #fc8181;
}

.alert-info {
    background: #bee3f8;
    color: #2a4365;
    border: 1px solid #90cdf4;
}

/* Admin styles */
.admin-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
}

.admin-table th,
.admin-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #e2e8f0;
}

.admin-table th {
    background: #f7fafc;
    font-weight: 600;
    color: #4a5568;
}

.admin-table tr:hover {
    background: #f7fafc;
}

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

.badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-success {
    background: #c6f6d5;
    color: #22543d;
}

.badge-secondary {
    background: #e2e8f0;
    color: #4a5568;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.875rem;
}

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

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

.setting-item {
    padding: 20px;
    border-bottom: 1px solid #e2e8f0;
}

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

.setting-header {
    margin-bottom: 10px;
}

.setting-description {
    color: #718096;
    font-size: 0.9rem;
    margin-left: 10px;
}

.setting-value {
    display: flex;
    align-items: center;
    gap: 10px;
}

.form-input {
    padding: 8px 12px;
    border: 2px solid #e2e8f0;
    border-radius: 6px;
    font-size: 0.9rem;
    transition: border-color 0.3s ease;
}

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

.ml-10 {
    margin-left: 10px;
}

.nav a.active {
    background: rgba(255,255,255,0.2);
    padding: 8px 16px;
    border-radius: 6px;
}

/* History page styles */
.filter-controls {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}

.filter-controls label {
    font-weight: 600;
    color: #4a5568;
}

.filter-controls select {
    padding: 8px 12px;
    border: 2px solid #e2e8f0;
    border-radius: 6px;
    font-size: 0.9rem;
    background: white;
    cursor: pointer;
}

.filter-controls select:focus {
    outline: none;
    border-color: #667eea;
}

.history-day {
    margin-bottom: 25px;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    overflow: hidden;
}

.history-day-header {
    background: #f7fafc;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #e2e8f0;
}

.history-day-header h4 {
    margin: 0;
    color: #4a5568;
    font-size: 1.1rem;
}

.day-total {
    font-weight: 600;
    color: #667eea;
    font-size: 1rem;
}

.history-records {
    padding: 0;
}

.history-record {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    border-bottom: 1px solid #f1f5f9;
    transition: background-color 0.2s ease;
}

.history-record:last-child {
    border-bottom: none;
}

.history-record:hover {
    background: #f8fafc;
}

.history-record.locked {
    opacity: 0.7;
    background: #f9fafb;
}

.record-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.record-time {
    font-weight: 600;
    color: #4a5568;
    min-width: 80px;
}

.record-amount {
    color: #667eea;
    font-weight: 500;
}

.locked-indicator {
    font-size: 0.9rem;
    opacity: 0.6;
}

.record-actions {
    display: flex;
    gap: 8px;
}

.no-data {
    text-align: center;
    color: #718096;
    font-style: italic;
    padding: 40px 20px;
}

.error {
    text-align: center;
    color: #e53e3e;
    padding: 40px 20px;
}

/* Modal styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal:not(.hidden) {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
}

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

.modal-header h3 {
    margin: 0;
    color: #4a5568;
}

.close {
    font-size: 1.5rem;
    cursor: pointer;
    color: #a0aec0;
    transition: color 0.2s ease;
}

.close:hover {
    color: #4a5568;
}

.modal-body {
    padding: 25px;
}

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

/* Form styles for history page */
.form-group input[type="datetime-local"],
.form-group input[type="number"] {
    width: 100%;
    padding: 12px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.3s ease;
}

.form-group input[type="datetime-local"]:focus,
.form-group input[type="number"]:focus {
    outline: none;
    border-color: #667eea;
}

/* Responsive styles for history page */
@media (max-width: 768px) {
    .filter-controls {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .history-record {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    
    .record-actions {
        width: 100%;
        justify-content: flex-end;
    }
    
    .modal-content {
        width: 95%;
        margin: 10px;
    }
    
    .modal-actions {
        flex-direction: column;
    }
    
    .modal-actions .btn {
        width: 100%;
        margin: 0;
    }
}
