/* ============================================================================
   GLOBAL STYLES
   ============================================================================ */

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.container {
    width: 100%;
    max-width: 600px;
}

/* ============================================================================
   CALCULATOR CONTAINER
   ============================================================================ */

.calculator {
    background: #2b2b2b;
    border-radius: 15px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
    overflow: hidden;
}

/* ============================================================================
   HEADER
   ============================================================================ */

.header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 20px;
    text-align: center;
    color: white;
}

.header h1 {
    font-size: 28px;
    margin-bottom: 5px;
}

.header p {
    font-size: 14px;
    opacity: 0.9;
}

/* ============================================================================
   MODE TOGGLE
   ============================================================================ */

.mode-toggle {
    display: flex;
    background: #1f1f1f;
    padding: 10px;
    gap: 10px;
}

.mode-btn {
    flex: 1;
    padding: 12px;
    border: none;
    background: #3c3c3c;
    color: #ffffff;
    font-size: 14px;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.3s;
}

.mode-btn:hover {
    background: #4c4c4c;
}

.mode-btn.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    font-weight: bold;
}

/* ============================================================================
   MODE CONTENT
   ============================================================================ */

.mode-content {
    display: none;
    padding: 20px;
}

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

/* ============================================================================
   STANDARD CALCULATOR DISPLAY
   ============================================================================ */

.display {
    margin-bottom: 20px;
}

.display input {
    width: 100%;
    padding: 20px;
    font-size: 32px;
    text-align: right;
    border: none;
    background: #1f1f1f;
    color: #ffffff;
    border-radius: 8px;
    font-family: 'Courier New', monospace;
}

/* ============================================================================
   CALCULATOR BUTTONS
   ============================================================================ */

.buttons {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}

.btn {
    padding: 20px;
    font-size: 20px;
    border: none;
    background: #3c3c3c;
    color: #ffffff;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
}

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

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

.btn-func {
    background: #d32f2f;
    color: white;
}

.btn-func:hover {
    background: #b71c1c;
}

.btn-operator {
    background: #ff6f00;
    color: white;
}

.btn-operator:hover {
    background: #e65100;
}

.btn-equals {
    background: #00c853;
    color: white;
}

.btn-equals:hover {
    background: #00a344;
}

/* ============================================================================
   AI MODE STYLES
   ============================================================================ */

.ai-input-section {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.ai-input-section label {
    color: #ffffff;
    font-size: 16px;
    font-weight: 500;
}

.ai-input-section textarea {
    width: 100%;
    padding: 15px;
    font-size: 14px;
    border: 2px solid #3c3c3c;
    background: #1f1f1f;
    color: #ffffff;
    border-radius: 8px;
    resize: vertical;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    min-height: 120px;
}

.ai-input-section textarea::placeholder {
    color: #888888;
}

.solve-btn {
    padding: 15px 30px;
    font-size: 16px;
    font-weight: bold;
    border: none;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
}

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

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

/* ============================================================================
   AI RESULT DISPLAY
   ============================================================================ */

.ai-result {
    margin-top: 20px;
    padding: 20px;
    background: #1f1f1f;
    border-radius: 8px;
    border-left: 4px solid #667eea;
}

.ai-result.hidden {
    display: none;
}

.ai-result h3 {
    color: #ffffff;
    margin-bottom: 15px;
    font-size: 24px;
}

.ai-result h3 span {
    color: #667eea;
}

.explanation {
    margin-top: 15px;
}

.explanation h4 {
    color: #ffffff;
    margin-bottom: 10px;
    font-size: 16px;
}

.explanation pre {
    background: #2b2b2b;
    padding: 15px;
    border-radius: 8px;
    color: #ffffff;
    font-size: 14px;
    white-space: pre-wrap;
    word-wrap: break-word;
    font-family: 'Courier New', monospace;
    line-height: 1.6;
    overflow-x: auto;
}

/* ============================================================================
   BOTTOM BUTTONS
   ============================================================================ */

.bottom-buttons {
    display: flex;
    gap: 10px;
    padding: 10px 20px 20px 20px;
}

.bottom-btn {
    flex: 1;
    padding: 12px;
    font-size: 14px;
    border: none;
    background: #3c3c3c;
    color: #ffffff;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
}

.bottom-btn:hover {
    background: #4c4c4c;
    transform: translateY(-2px);
}

/* ============================================================================
   MODAL STYLES
   ============================================================================ */

.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.7);
}

.modal-content {
    background-color: #2b2b2b;
    margin: 5% auto;
    border-radius: 15px;
    width: 90%;
    max-width: 700px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    max-height: 80vh;
    display: flex;
    flex-direction: column;
}

.modal-header {
    padding: 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 15px 15px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    margin: 0;
    font-size: 24px;
}

.close {
    color: white;
    font-size: 35px;
    font-weight: bold;
    cursor: pointer;
    line-height: 1;
}

.close:hover,
.close:focus {
    opacity: 0.7;
}

.modal-body {
    padding: 20px;
    color: #ffffff;
    overflow-y: auto;
    flex: 1;
}

.modal-body ul {
    list-style-position: inside;
    margin-left: 20px;
}

.modal-body li {
    margin: 10px 0;
    line-height: 1.6;
}

.modal-body ul ul {
    margin-left: 20px;
}

.modal-footer {
    padding: 15px 20px;
    border-top: 1px solid #3c3c3c;
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.modal-btn {
    padding: 10px 20px;
    border: none;
    background: #505050;
    color: white;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s;
}

.modal-btn:hover {
    background: #606060;
}

.modal-btn.btn-danger {
    background: #d32f2f;
}

.modal-btn.btn-danger:hover {
    background: #b71c1c;
}

/* ============================================================================
   HISTORY CONTENT STYLES
   ============================================================================ */

.history-entry {
    background: #1f1f1f;
    padding: 15px;
    margin-bottom: 15px;
    border-radius: 8px;
    border-left: 4px solid #667eea;
}

.history-entry h4 {
    color: #667eea;
    margin-bottom: 8px;
}

.history-entry p {
    margin: 5px 0;
    line-height: 1.5;
}

.history-entry pre {
    background: #2b2b2b;
    padding: 10px;
    border-radius: 5px;
    margin-top: 10px;
    font-size: 13px;
    white-space: pre-wrap;
    word-wrap: break-word;
}

/* ============================================================================
   RESPONSIVE DESIGN
   ============================================================================ */

@media (max-width: 600px) {
    .header h1 {
        font-size: 24px;
    }

    .mode-btn {
        font-size: 12px;
        padding: 10px;
    }

    .display input {
        font-size: 24px;
        padding: 15px;
    }

    .btn {
        padding: 15px;
        font-size: 18px;
    }

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