/* Base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: #f5f5f5;
    padding: 20px;
}

.container {
    max-width: 600px;
    margin: 0 auto;
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    padding: 30px;
}

h1 {
    color: #333;
    margin-bottom: 10px;
    font-size: 28px;
}

.subtitle {
    color: #666;
    margin-bottom: 30px;
    font-size: 14px;
}

.form-section {
    margin-bottom: 30px;
}

.form-section h2 {
    color: #444;
    font-size: 16px;
    margin-bottom: 15px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

input[type="text"],
input[type="time"] {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    margin-bottom: 15px;
    transition: border-color 0.3s;
}

input[type="text"]:focus,
input[type="time"]:focus {
    outline: none;
    border-color: #4CAF50;
    box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.1);
}

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

button {
    padding: 12px 16px;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-preset {
    background-color: #e8f5e9;
    color: #2e7d32;
    border: 1px solid #4CAF50;
}

.btn-preset:hover {
    background-color: #4CAF50;
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.btn-submit {
    width: 100%;
    background-color: #4CAF50;
    color: white;
    padding: 14px;
    font-size: 16px;
    font-weight: 600;
}

.btn-submit:hover {
    background-color: #45a049;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.btn-submit:active {
    transform: translateY(0);
}

.message {
    padding: 15px;
    border-radius: 4px;
    margin-bottom: 20px;
    word-wrap: break-word;
    white-space: pre-wrap;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 13px;
    line-height: 1.5;
}

.message.success {
    background-color: #e8f5e9;
    color: #2e7d32;
    border: 1px solid #4CAF50;
}

.message.error {
    background-color: #ffebee;
    color: #c62828;
    border: 1px solid #f44336;
}

.input-group {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 10px;
    align-items: flex-end;
}

.input-group input {
    margin-bottom: 0;
}

@media (max-width: 480px) {
    .container {
        padding: 20px;
    }

    .buttons-grid {
        grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    }

    .input-group {
        grid-template-columns: 1fr;
    }
}

/* Madd page styles */
.container.madd-page {
    max-width: 1400px;
}

#undoButton:hover {
    background-color: #ff5252 !important;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

#undoButton:active {
    transform: translateY(0);
}

.madd-container {
    display: grid;
    grid-template-columns: 250px 1fr 250px;
    gap: 20px;
    grid-template-rows: auto;
    align-items: start;
}

.sidebar {
    padding: 15px;
    border-radius: 4px;
    background-color: #f5f5f5;
    border: 1px solid #ddd;
    max-height: 600px;
    overflow-y: auto;
    grid-row: 1;
}

.sidebar:first-child {
    grid-column: 1;
}

.sidebar:last-child {
    grid-column: 3;
}

.sidebar h3 {
    margin-top: 0;
    font-size: 16px;
    margin-bottom: 12px;
    color: #333;
}

.sidebar-empty {
    color: #999;
    font-size: 13px;
    font-style: italic;
}

.deed-item {
    padding: 8px 10px;
    margin-bottom: 8px;
    border-radius: 3px;
    font-size: 13px;
    background-color: white;
    border-left: 4px solid #4CAF50;
}

.deed-item.negative {
    border-left-color: #f44336;
    background-color: #ffebee;
}

.deed-item-name {
    font-weight: 600;
    color: #333;
}

.deed-item-amount {
    font-weight: 600;
    margin-left: 8px;
}

.deed-item-amount.positive {
    color: #4CAF50;
}

.deed-item-amount.negative {
    color: #f44336;
}

.deed-item-time {
    display: block;
    font-size: 11px;
    color: #999;
    margin-top: 4px;
}

.main-content {
    grid-column: 2;
    grid-row: 1;
}

.btn-preset.disabled {
    opacity: 0.4;
    cursor: not-allowed;
    background-color: #e0e0e0 !important;
    color: #999 !important;
}

.inline-inputs {
    display: flex;
    gap: 15px;
    align-items: flex-end;
}

.inline-field {
    display: flex;
    flex-direction: column;
}

.inline-field input {
    margin-bottom: 0;
}

.deed-field {
    flex: 0 0 225px;
}

.time-field {
    flex: 1;
}

@media (max-width: 1024px) {
    .madd-container {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto auto;
    }

    .main-content {
        grid-column: 1;
        grid-row: 1;
        order: 1;
    }

    .sidebar:first-child {
        grid-column: 1;
        grid-row: 2;
        order: 2;
    }

    .sidebar:last-child {
        grid-column: 1;
        grid-row: 3;
        order: 3;
    }

    .sidebar {
        max-height: none;
    }

    .inline-inputs {
        flex-direction: column;
        align-items: stretch;
    }

    .deed-field {
        flex: 1;
    }
}

/* Query page styles */
.container.query-page {
    max-width: 1200px;
}

.query-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.editor-section {
    background-color: white;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 20px;
}

.editor-label {
    font-size: 14px;
    font-weight: 600;
    color: #333;
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

#sqlInput {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 13px;
    line-height: 1.5;
    min-height: 200px;
    resize: vertical;
    background-color: #f9f9f9;
}

#sqlInput:focus {
    outline: none;
    border-color: #4CAF50;
    box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.1);
}

.editor-buttons {
    display: flex;
    gap: 10px;
    margin-top: 15px;
}

.btn-execute {
    background-color: #4CAF50;
    color: white;
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-execute:hover {
    background-color: #45a049;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.btn-execute:active {
    transform: translateY(0);
}

.btn-execute:disabled {
    background-color: #ccc;
    cursor: not-allowed;
    transform: none;
}

.results-section {
    background-color: white;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 20px;
    display: none;
}

.results-section.active {
    display: block;
}

.results-header {
    font-size: 14px;
    font-weight: 600;
    color: #333;
    margin-bottom: 15px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.results-sql {
    background-color: #f5f5f5;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 12px;
    margin-bottom: 15px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 12px;
    line-height: 1.5;
    overflow-x: auto;
    color: #333;
}

.results-table {
    width: 100%;
    border-collapse: collapse;
    border: 1px solid #ddd;
    border-radius: 4px;
    overflow: hidden;
    margin-top: 10px;
}

.results-table thead {
    background-color: #f9f9f9;
}

.results-table th {
    padding: 12px;
    text-align: left;
    border-bottom: 2px solid #ddd;
    font-weight: 600;
    color: #333;
    font-size: 13px;
}

.results-table td {
    padding: 10px 12px;
    border-bottom: 1px solid #eee;
    font-size: 13px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    word-break: break-all;
    max-width: 500px;
}

.results-table tbody tr:hover {
    background-color: #f5f5f5;
}

.results-count {
    color: #666;
    font-size: 13px;
    margin-top: 10px;
}

.error-message {
    background-color: #ffebee;
    border: 1px solid #f44336;
    border-radius: 4px;
    padding: 15px;
    color: #c62828;
    margin-bottom: 20px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 13px;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.loading {
    display: none;
    color: #666;
    font-size: 13px;
}

.loading.active {
    display: block;
}

.sql-highlight {
    background-color: #f5f5f5;
    padding: 1px 0;
}

.sql-keyword { color: #0066cc; font-weight: bold; }
.sql-string { color: #008000; }
.sql-number { color: #ff6600; }
.sql-literal { color: #0066cc; }

/* Calendar page styles */
.calendar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.calendar-header h1 {
    margin-bottom: 0;
}

.nav-btn {
    background-color: #e8f5e9;
    color: #2e7d32;
    border: 1px solid #4CAF50;
    padding: 8px 16px;
    text-decoration: none;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s;
}

.nav-btn:hover {
    background-color: #4CAF50;
    color: white;
}

.calendar-nav {
    display: flex;
    gap: 10px;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
    margin-bottom: 20px;
}

.calendar-day-header {
    text-align: center;
    font-weight: 600;
    color: #666;
    padding: 10px 0;
    font-size: 12px;
    text-transform: uppercase;
}

.calendar-day {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    border: 2px solid transparent;
}

.calendar-day.empty {
    cursor: default;
}

.calendar-day.gray {
    background-color: #e0e0e0;
    color: #666;
}

.calendar-day.green {
    background-color: #4CAF50;
    color: white;
}

.calendar-day.pink {
    background-color: #ffcdd2;
    color: #c62828;
}

.calendar-day.today {
    border-color: #333;
}

.calendar-day.future {
    opacity: 0.4;
    cursor: not-allowed;
}

.calendar-day:not(.empty):not(.future):hover {
    transform: scale(1.1);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.back-link {
    display: inline-block;
    margin-top: 20px;
    color: #4CAF50;
    text-decoration: none;
    font-size: 14px;
}

.back-link:hover {
    text-decoration: underline;
}

/* Madd page additional styles */
.btn-undo {
    background-color: #ff6b6b;
    color: white;
    padding: 14px 16px;
    font-size: 14px;
    font-weight: 600;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s;
    flex: 0 0 auto;
    white-space: nowrap;
}

.btn-row {
    display: flex;
    gap: 10px;
}

.btn-row .btn-submit {
    flex: 1;
}

.btn-calendar {
    background-color: #2196F3;
    color: white;
    padding: 12px 24px;
    font-size: 14px;
    font-weight: 600;
    border-radius: 4px;
    text-decoration: none;
    display: inline-block;
}

.btn-reprust {
    background-color: #8A2BE2;
    padding: 12px;
    border-radius: 4px;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
}

.btn-reprust-icon {
    width: 18px;
    height: 18px;
    border-radius: 4px;
    display: block;
}

/* Same shape as the Reprust button, the plants app's own green. */
.btn-plants {
    background-color: #30d158;
    padding: 12px;
    border-radius: 4px;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
}

.btn-plants-icon {
    width: 18px;
    height: 18px;
    border-radius: 4px;
    display: block;
}

.madd-footer {
    margin-top: 12px;
    border-top: 1px solid #ddd;
    padding-top: 10px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
}
